Actually speaking, the question is formulated in the title of the topic?
|
1 answer
- id has a higher priority in css than class.
- The id must be unique to the entire html document.
- class can be combined with other classes, separated by a space, and id not.
id creates an object with the same name in the window space , which can be accessed via js. For example:
<p id="some_id">Мир</p> <p id="ff-ff">Привет</p> <script> some_id.innerHTML = 'Иван'; alert(window["ff-ff"].innerHTML); </script>
- 3The fourth point about the fact that an object is created is not true, check for yourself. Also according to the standard id can contain "-", which is perceived as a difference operator in js. And for good reason there is a
document.getElementById()method :) - Alex - got it Thank you all - Muscled Boy
- 2@Alex, the field with
-in the title can not be accessed through a dot, otherwise it is the same field accessible through[]- Grundy - 2@Alex, added a link to a piece of the standard talking about it, if you do not believe, look there) - Duck Learns to Take Cover
- 2@Alex, I also did not believe it at first, but opened the js-console and drove it in - and there is)) andreymal
|
idunique andclassnot. And an object can have several class. - gil9red