<div id="goods"></div>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script>
var obj= [{id: 1, pId: 0, name: "采购商品", open: true}, {id: 2, pId: 1, name: "雨伞2", open: true}, {id: 2, pId: 1, name: "雨伞2", open: true}, {id: 2, pId: 1, name: "雨伞2", open: true}];
var html='';
$.each(obj,function (i,v) {
var ul='';
ul+='<a href="index.php?goods_id='+v.id+'">'+i+'===='+v.name+'</a>';
html+=ul;
});
$('#goods').append(html);
alert(html)
var table='';
$.each([{name:"xym",email:"123456@qq.com"},{name:"zhima",email:"hill@qq.com"}],function(i,n)
{
// alert("索引:"+i+"对应值为:"+n.name);//其中表示索引,n表示对象;
var td='';
td+='<td style="background: red" onclick="showdata(\''+n.email+'\'+\',\'+\''+n.name+'\');">'+n.name+'</td>';
table+=td;
});
<td style="background: red" οnclick="showdata('123456@qq.com'+','+'xym');">xym</td><td style="background: red" οnclick="showdata('hill@qq.com'+','+'zhima');">zhima</td>
执行jquery都要事先引入jquery包
在线jquery包引入
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>