for (var i = 0; i < pcities.length; i++) {
//pcities[i]//{name: "兴安盟", id: 438}
str2 += '<li onclick="selectcity('+ pcities[i].id+','+pcities[i].name +');"><i class="datadd" ></i></li>';
}
cittty.innerHTML = str2; for (var i = 0; i < pcities.length; i++) {
oI[i].innerHTML = pcities[i].name;
oI[i].id = pcities[i].id;
}我想给每一个li写一个方法selectcity,传他的id和name,但是我点击兴安盟,就会报"兴安盟 is not defined",参数直接写pcities[i]就变成"selectcity([object Object]);",我应该怎么处理传的参数呢。
2 回答
暮色呼如
TA贡献1853条经验 获得超9个赞
for (var i = 0; i < pcities.length; i++) { //pcities[i]//{name: "兴安盟", id: 438} str2 += '<li onclick="selectcity(\''+ pcities[i].id+'\',\''+pcities[i].name +'\');"><i class="datadd" ></i></li>'; }
- 2 回答
- 0 关注
- 986 浏览
添加回答
举报
0/150
提交
取消