js 获取dom的class

js 获取节点的class

方式一:使用getAttribute

var x = document.getElementsByTagName("H1")[0].getAttribute("class");

方式二:

let oneSwipe=childrenSwipeOptions[i];
let className=oneSwipe.className;

 参考:http://www.w3schools.com/jsref/met_element_getattribute.asp

http://www.w3schools.com/jsref/prop_html_classname.asp

相关推荐