Browse - programming tips - jquery select by nameDate: 2011feb3 Language: javaScript Q. With jQuery, how do you select an element by name (not id) ? A. If you have <input name=myfield> You select it with [name=myfield] like this: <script> value = $('[name=myfield]').val(); // or $('[name=myfield]').change(function{} { alert('it changed'); }); </script> My feeling is that if you already have a name for a field why add an id just to select it.
Add a commentSign in to add a comment | Advertisements:
|