Problems with jquery and a special selector
Friends, I have a problem, now I want to access an element with jquery li, unfortunately these li elements have the ids as follows:
<li id='abc-2\textb开发者_StackOverflow中文版ox'>...</li>
<li id='xop-2\listbox'>...</li>
I tried to get the item by the following expressions, but none work.
$('#abc-2\textbox')
$('#abc-2\\textbox')
$('#abc-2//\textbox')
$('#abc-2\\\textbox')
I guess the problem is the \ character, Could someone help me?
$('#abc-2\\\\textbox') (use 4 slashes)
This is from the HTML 4 Spec
ID and NAME tokens must begin with a letter [A-Za-z] and may be followed by any number of letters, digits [0-9], hyphens "-", underscores "_", colons ":", and periods ".".
Again that means alpha-numeric with the addition of hyphens, underscores, colons and periods.
The backslash is an illegal character for the id. See here.
If there's another way to construct your selection (is the location of the LI
predictably relative to another element with a valid ID?) -- that would be your best bet.
精彩评论