what is the difference between ID selector and class selector in jQuery?

Started by mvminfotech, October 03, 2018, 01:08:05 AM


Netparticle

ID's should be unique on the page when you have multiple elements with same ID's, jQuery selects only the first one. That's because it doesn't have to bother looking for others as there isn't supposed to be anymore – that might explain the weird behavior you're experiencing.
If you want multiple elements to have the same functionality, give them the same class. If you want to identify a specific element, give it an id. This isn't limited to just jQuery, but to HTML and CSS overall.

Citywebpuneind

Difference between id and class attribute: The only difference between them is that "id" is unique in a page and can only apply to at most one element, while "class" selector can apply to multiple elements