一、innerText和innerHTML
- 都是用来操作标签的内容的
- 区别
-innerText只会操作文本内容,如果有标签,不生效
-innerHTML:能够操作HTML标签,标签能够生效 - 推荐使用innerText, 更加安全
二、表单的属性
-
value
-京东的搜索效果 -
布尔属性
-值只有true和false
-disabled
-checked
-selected
-随机翻牌子<body> <button id="btn">翻牌子</button> <select name="" id=""> <option value="">刘枝富</option> <option value="" selected>法制兵</option> <option value="">方玉红</option> <option value="">张玉珂</option> <option value="">张飞</option> <option value="">姜国欣</option> </select> <script> var btn = document.getElementById('btn'); var options = document.getElementsByTagName('option'); btn.onclick = function(){ var index = parseInt(Math.random() * options.length); options[index].selected = true; } </script> </body>
-全选案例
<body> <div class="wrap"> <table> <thead> <tr> <th> <inpu