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"; } 

http://jsfiddle.net/pwf4z/

jquery

  $("li").addclass("classname"); 

Comments

Popular posts from this blog

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

keyboard - Smiles and long press feature in Android -

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