Click here to Skip to main content
15,917,538 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am new to web development. I tried foll:
var a = $('.<classname>');
and then for first element a[0]
but when i use some function as a[0].fadeIn() it gives my error that there is no such function. Pls help me. How to do it?

What I have tried:

var a = $('.<classname>');
a[0].<function>;
Posted
Updated 24-Dec-17 16:45pm

There are a number of ways, an example here Class Selector[^]
Bookmark this page jQuery Selectors[^]
 
Share this answer
 
a[0] is a pure javascript object, you cannot apply jquery function to it, instead you shall use .first() [^]

$('.classname').first().fadeIn();
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900