参考:https://www.cnblogs.com/jiuyi/p/4223836.html
参考:http://yuncode.net/code/c_59631c91b2f8372
参考:https://cloud.tencent.com/developer/article/1466053
项目经常需要用到的方法,总结一下,方便以后查询:
- JS函数修改html的元素内容,及修改属性内容
document.getElementById("aid").innerHTML="World";
document.getElementById("aid").href="http://www.jikexueyuan.com";
document.getElementById("aid").style="width:120px";
document.getElementById("aid").style.color="blue";
document.getElementById("aid").setAttribute("class", "abc");
document.getElementById("aid").className ="abc";
- JS操作自定义设置
<!-- JS操作自定义属性 -->
<input type="text" id="txtBox" displayName="123456" />
// 获取自定义属性值:
document.getElementById("txtBox").getAttribute("displayName");
document.getElementById("txtInput").attributes["displayName"].nodeValue
// 设置自定义属性值:
document.all.txtBox.setAttribute("displayName ","123456");
document.getElementById("txtInput").attributes["displayName"].nodeValue = "123456"