JQuery selector value escaping
Posted
by
user53794
on Stack Overflow
See other posts from Stack Overflow
or by user53794
Published on 2009-04-11T07:40:43Z
Indexed on
2012/06/10
4:40 UTC
Read the original article
Hit count: 191
I have a dropdown list that contains a series of options:
<select id=SomeDropdown>
<option value="a'b]<p>">a'b]<p></option>
<option value="easy">easy</option>
<select>
Notice that the option value/text contains some nasty stuff:
- single quotes
- closing square bracket
- escaped html
I need to remove the a'b]<p> option but I'm having no luck writing the selector. Neither:
$("#SomeDropdown >option[value='a''b]<p>']");
or
$("#SomeDropdown >option[value='a\'b]<p>']");
are returning the option.
What is the correct way to escape values when using the "value=" selector?
© Stack Overflow or respective owner