Hw can i select component with id, which contain [ ] symbols?
for example:
<div id=divtables[COURSE_SUBJECTS][141][TITLE]>gg</div>
Tnx.
Hw can i select component with id, which contain [ ] symbols?
for example:
<div id=divtables[COURSE_SUBJECTS][141][TITLE]>gg</div>
Tnx.
[] symbols aren't valid id characters. If you want to try it out, use a double backslash:
$("#divtables\\[COURSE_SUBJECTS\\]")
You just need to escape them, like this:
$("#divtables\\[COURSE_SUBJECTS\\]\\[141\\]\\[TITLE\\]")
There's a full FAQ/how-to on the escaping topic here, this works for any selector type, though you should have different IDs values possible (ones that don't result in invalid HTML mainly). I know this isn't always the case, e.g. content generated by another system, the solution above works for this, but it's not the best solution, replacing any invalid characters would be best, I'd suggest this:
<div id="divtables-COURSE_SUBJECTS-141-TITLE">gg</div>
Then your selector doesn't need any tricks, it's just:
$("#divtables-COURSE_SUBJECTS-141-TITLE")
This is not a valid id according to W3C:
Naming rules:
Must begin with a letter A-Z or a-z
Can be followed by: letters (A-Za-z), digits (0-9), hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
Values are case-sensitive
This basically says that you should not have [] in an id. I would strongly suggest you following the standards.
As per w3c standards you cannot use [] for an ID property in HTML. That means you can only use the following characters for ID property.
Letters ([A-Za-z])
digits ([0-9])
hyphens ("-")
underscores ("_")
colons (":")
periods (".").