javascript - How to add class to img element in array? -


simply trying add class img in array

aftarray = $('.aft'); // creates array of html imgs aftarray[0].addclass('currenttest'); // should change css adding class 

here resulting error ff

[12:53:18.593] typeerror: aftarray[0].addclass not function... 

wtf? thanks!

you trying call addclass on dom object instead of jquery object. indexer gives ojbect need use eq() jquery object.

aftarray.eq(0).addclass('currenttest'); 

you not have iterate in particular case.

$('.aft').addclass('currenttest'); 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -