What is difference jQuery selectors

Like

$(':input[type="text"]')

versus

$(':input').is( "[type=text]" );

versus

$('input').is( "[type=text]" );

Thanks

Take a look here: https://stackoverflow.com/questions/14863751/input-vs-input-in-jquery

input is a DOM selector, will select all input tags. :input is a jquery-specific selector, will include button, textarea, etc.

1 Like

[What is difference jQuery selectors]

The difference is that $('.ajaxLink').on('click', function (e) { ... } only binds elements that already exists.

$(document).on('click', '.ajaxLink', function (e) { ... } has an delegate and also binds .ajaxLink elements that are created dynamically in the future.

If you want an delegate you really should use a parent that is closer to the child elements than document . The reason being that is saves unnecessary searches in the DOM tree, which gives better performance.

1 Like