In several jquery tutorials, separate ID
and Class
are used for JS
and CSS
. for example
<div id="test" class="test">TEST</div>
As ID
is used in the jQuery code, and Class
is used in CSS
. To me it is easier to not introduce Class
and use ID
for CSS rule too. Is there any advantage to use css-less ID
for javascript?
EDIT: Thanks folks! I know the difference between ID
and Class
; I am asking why some use separate ID
and Class
for JS
and CSS
when one is sufficient. Here, the matter is the necessity for uniqueness of ID
. The case is separating JS and CSS tasks (while they are closely entangled).
EDIT2: As requested, I give a typical example: this Tutorial. Look for actionsBox
; .actionsBox
has been used for CSS
and #actionsBox
for JS
. As you can see there is only one <div>
so ID
would be enough for styling.