Class or identifier

Duplicate:

Someday, when I like to make choices, add an identifier (unique) to something (images), and I used jquery to do something on hover or click.

But the same thing can be done with classes. I understand that a class is for many things (let's say class = "selected"), but when the class adds something, I can run the jQuery action with this insted ID class ...

So the question is, what is the “right way” to use class and identifier if I can accomplish anything and everything with both!

+3
4

, , , . div, , . , , .

- . JavaScript, - . ID , . , , " " . , , , , , , "", "", " " " ..

+6

, - , HTML-.

, , . , , , , "" ID "entry",

+2

HTML , , .

+1

, "" - , .

:

  • , , , .
  • , iframe , .
  • , , - , - document.getElementById(). , CSS, , , . , . , .
0
source

Source: https://habr.com/ru/post/1705940/


All Articles