Thursday, February 18, 2016

jQuery selector escape square brackets to select element

jQuery selector escape square brackets to select element

If you feel more comfortable without escaping you also use the attributes selector and search for the element with that id like this:

$('[id="meta[152][value]"]')

From the jQuery documentation:

To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\.

Reference:

http://stackoverflow.com/questions/8404037/jquery-escape-square-brackets-to-select-element

http://stackoverflow.com/questions/18573178/what-is-the-difference-between-these-different-ways-to-escape-square-brackets-in

No comments: