html - How to add an class to all the li tags with javascript -
i'm trying give (via javascript) li tags on html page class. best way this?
javascript
var elm = document.getelementsbytagname('li') var length = elm.length; (var = 0; < length; i++) { elm[i].classname = elm[i].classname + " classname"; }
jquery
$("li").addclass("classname");
Comments
Post a Comment