@name selector is deprected in jQuery, removed in jQuery 1.3
Posted January 23rd, 2009 in Javascript
In my how to check and uncheck a checkbox with jQuery and how to get and set form element values with jQuery posts I used @name= selectors for some of the form elements but have since discovered the use of the @ was already deprecated and has been removed in jQuery 1.3.
One of my previous examples looked like this, to work out if a checkbox was checked:
$('input[@name=foo]').is(':checked')
$('input[@name=foo]').attr('checked')
To make the code valid for jQuery 1.3 you need to remove the @ symbols and do this instead:
$('input[name=foo]').is(':checked')
$('input[name=foo]').attr('checked')
The use of these selectors without the @ also works in the jQuery 1.2 branch. I am not sure if it works in older versions.
Related posts:
- Accessing form elements by name with jQuery (Tuesday, June 23rd 2009)
- Dynamically get and set an elements content with jQuery (Sunday, January 11th 2009)
- Adding, removing and checking if an element has a CSS class with jQuery (Tuesday, December 16th 2008)
- How to check and uncheck a checkbox with jQuery (Friday, November 14th 2008)
- How to get and set form element values with jQuery (Thursday, November 13th 2008)

Comments
blog comments powered by Disqus