There is a single link containing various div classes:
<a class='div1 otherdiv alignleft'>Link</a>
I want to extract the first class of this link and store it in a variable. How can I achieve this without knowing the specific name of the first class?
Since the name of the first div class may vary, I cannot declare a fixed variable like var firstdiv = div1
Is there a way to retrieve the name of the first class and save it in a variable for later use in a function? For example:
var firstdiv = ('a').first();
Then utilize this variable in a function:
$(firstdiv).click(function(){
// my function
});
How can I accurately identify the name of the initial div within the a tag?