Reputation: 387
So I have someone else's old code that I am trying to restore. I am not too familiar with jQuery, but what does the @
operator specify?
The code is:
v_button_format = $('#' + v_form_id).find('input[@name=button_format]').val();
v_content_type = $('#' + v_form_id).find('input[@name=content_type]').val();
I am using jQuery 1.3 and it's throwing an "uncaught exception: Syntax error, unrecognized expression: [@name=button_format]" error. Is there a compatibility issue?
Upvotes: 5
Views: 385
Reputation: 16835
input[@name=button_format]
This is old selector type.please remove if @ if you using jQuery latest new way is
input[name="button_format"]
Upvotes: 0
Reputation: 82028
That means attribute
. input[@name=button_format]
means the input tag with the name attribute equal to button_format
.
You will need to remove the @ and quote button_format in recent versions jQuery, however. This means @
is not backwards compatible. So quoth the docs.
Note: In jQuery 1.3 [@attr] style selectors were removed (they were previously deprecated in jQuery 1.2). Simply remove the “@” symbol from your selectors in order to make them work again.
Upvotes: 3
Reputation: 21878
Attribute as others mentioned.
My 2-cents: The notation is inspired from XPath, which also denotes (XML) attributes using an @
Upvotes: 0
Reputation: 72672
That's the OLD way of doing it.
It is the same as (and should be changed to):
$('input[name="button_format"]')
Also note the mandatory quotes
Upvotes: 0
Reputation: 12294
Note: In jQuery 1.3 [@attr] style selectors were removed (they were previously deprecated in jQuery 1.2). Simply remove the '@' symbol from your selectors in order to make them work again.
it's a deprecated selector, you have to remove it from your code as it's no longer supported and will cause errors.
Upvotes: 0
Reputation: 24360
input[@name=button_format]
means the input field with the name-attribute set to 'button_format', ie:
<input name="button_format">
Upvotes: 0
Reputation: 887451
This is an attribute selector.
The @
is an XPath-ism that is no longer used in jQuery.
In addition, newer versions of jQuery require the attribute value to be in quotes.
Therefore, you should write
$('#' + v_form_id).find('input[name="content_type"]').val();
Upvotes: 13