I wanted to animate the green button, however, when I select the green button by specifying its id, I can apply fade in and fade out and it works properly. But when I select it using the class, the HTML code is shown as output in the console. Why are the outputs different even though I am selecting the same element through different identifiers.
Asked
Active
Viewed 39 times
0

Ayush Narang
- 11
-
1Because ID is unique and CLASS isn't – Alon Eitan Jan 16 '21 at 08:10
-
@Alon I have added [0] with the when I am using class. I guess it specifies that I am trying to access the first object. – Ayush Narang Jan 16 '21 at 08:13
-
When you access the 0th element it’s returning a native element. Otherwise it’s a jquery object. – Paul Rooney Jan 16 '21 at 08:29