I have tried to use setAttribute()
method in jquery as mentioned below :
$(p).setAttribute('class','first');
However that didn't work so I replaced setAttribute
with attr()
method.
$(p).attr('class','first');
It worked when I used the above code.
I just want to know why it didn't work when I used setAttribute()
and why it worked when I used attr()
?