Reputation: 198
I have this Html:
<li class="initial_list initial_first_item click_item" id="reviewsystems A">A</li>
When I run this script:
$('#reviewsystems').fadeOut(300);
It will not work. If I remove the A in the ID it will work. Is there a way to have multiple ID's without converting them to classes?
JsFiddle with Example: http://jsfiddle.net/5Lvf9/
Upvotes: 0
Views: 89
Reputation: 1700
An id
attribute for an HTML element should be unique for the document:
HTML5 Ref: http://www.w3.org/TR/html5/dom.html#the-id-attribute
HTML4 Ref: http://www.w3.org/TR/html401/struct/global.html#h-7.5.2
Further, the id may not contain spaces. It should begin with a letter followed by numerals, hyphens, underscores, colons or period characters:
HTML4 Ref: http://www.w3.org/TR/html401/types.html#type-name
If you want to select multiple HTML elements use the class
attribute instead.
Upvotes: 1
Reputation: 1373
No, the id has to be unique on the page and it cannot be a combination of multiple values / contain space characters.
Upvotes: 5
Reputation: 6668
You cannot have spaces in your id
Refer this http://www.w3.org/TR/html401/types.html#type-name
You can select using class #id. Here is a working fiddle
$(.class#id)...
Upvotes: 0