how to add a class attribute in a ul tag

This question already has an answer here:

  • Change an element's class with JavaScript 30 answers

  • Class should be className :

    ul.className="nav nav-pills nav-stacked";
    

    ...because JavaScript is case-sensitive, so Class and class aren't the same thing, and because when the DOM bindings for JavaScript were being created, they couldn't use class because at that time, in JavaScript, you couldn't write ul.class = ... because class was a reserved word and you couldn't use it in a property literal like that. (You can now, as of ES5 in 2009, but of course that was more than a decade after the bindings were created.)

    The other reflected attribute with an unusual name is htmlFor , which is for the for attribute (for instance, on label elements).

    链接地址: http://www.djcxy.com/p/25218.html

    上一篇: 使用id更改输入元素的类

    下一篇: 如何在ul标签中添加一个类属性