--用json的时候,知道id获取对应的name或者相反根据name获取id --内核代码 <script> var products=[{ID:1,Name:"a",Price:1},{ID:2,Name:"b",Price:4}]; for(var s in products) { alert("ID是:"+products[s].ID+"Name是:"+products[s].Name); } </sc
<div id="tests" class="a b c" style="color:#f00">123</div> var test = tests.firstChild.nodeValue; tests = tests.childNodes[0]; tests.insertData(0,789);//从前插入789 var t2 = document.querySelector("#tests");
先来看一个例子: 不获取 id 也可以使用 id 元素. <!-- Author: XiaoWen Create a file: 2017-01-11 13:58:01 Last modified: 2017-01-11 14:00:28 Start to work: Finish the work: Other information: --> <!DOCTYPE html> <html lang="en"> <head> <me