Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery @ operator?

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?

like image 955
BDUB Avatar asked Aug 25 '11 15:08

BDUB


1 Answers

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();
like image 85
SLaks Avatar answered Nov 03 '22 18:11

SLaks