0

In connection to having both Id and class sector

Why have Id and class sectors if the class sector is more superior and more functional?

1st Jan 2019, 6:14 AM
Patrick Opperman
Patrick Opperman - avatar
2 ответов
+ 7
Because class is mainly used for CSS purpose. But when you use JavaScript, you surely need a ID. Like : you defined two buttons : open and close. Both buttons have same class named btn. When you will define JavaScript with that class, both buttons will behave same which they are not supposed to.... But you give both of them IDs like open and close. You can define both independently. Hope this makes sense to you. https://www.lifewire.com/what-is-the-id-attribute-3468186
1st Jan 2019, 6:18 AM
Raj Chhatrala
Raj Chhatrala - avatar
0
Ok..O think I understand.Tank you sir..
1st Jan 2019, 6:35 AM
Patrick Opperman
Patrick Opperman - avatar