jquery - Which is the more efficient way for SELECT onchange? -


in jquery, have 2 ways select onchage:

1. use .change specifying name

html:

<select name="a">     <option value="1">1</option>     <option value="2">2</option>     <option value="3">3</option> </select> 

jquery:

$('select[name=a]').change(function(){     alert($(this).val()); }); 

2. use .change specifying id

html:

<select id="a">     <option value="1">1</option>     <option value="2">2</option>     <option value="3">3</option> </select> 

jquery:

$('#a').change(function(){       alert($(this).val()); }); 

so, given smaller or larger list of elements, 1 faster/more efficient when using jquery?

what best practice?

first of there lots of other ways select element (including select element) in jquery.
selecting elements id better supposed unique , gives results faster


Comments

Popular posts from this blog

How to access named pipes using JavaScript in Firefox add-on? -

multithreading - OPAL (Open Phone Abstraction Library) Transport not terminated when reattaching thread? -

node.js - req param returns an empty array -