Alone88
Suivre

Après avoir suivi, vous pouvez suivre ses informations dynamiques en temps opportun

Notes de cours
  • Cours dans la section correspondante:Ajouter, supprimer, modifier et vérifier des nœuds d'attributs : le moyen le plus efficace de contrôler les éléments

    ## **JavaScript增删改查** 第一种 .(点操作符) ```JavaScript 不加='',则是查看内容,加了就是增加或修改 var h2 = document.getElementsByTagName('h2');//先定义变量 h2.ClassName ='class'//增加或修改Class的内容 h2.Id = 'id'//增加或修改id的内容 h2.style.color ='red' //增加或修改style的内容,style. ``` 第二种:Attribute(属性) ``` h2.getAttribute('属性名')//获取属性; h2.setAttribute('属性名','要修改的内容')//修改 h2.removeAttribute('属性或元素')//删除 ``` 第三种:attributes ``` h2.attributes//获取属性 h2.attributes[索引]; h2.attributes['属性']; h2.attributes['属性'].nodeType='修改的内容'//修改 h2.attributes.removeNamedItem('属性')//删除内容

    2018-05-181个赞