代码给我:A B C当我单击ABC时,它总是向我显示最后一个“伏特加”。我想要“马丁”(对于A),“林赛”(对于B),“伏特加”(对于C)请在我的示例中帮我。myArray = [ { letter: "A", brand: "martin" }, { letter: "B", brand: "lindsay" }, { letter: "C", brand: "vodka" }]; var list = ''; for (var i = 0; i < myArray.length; i++) { list += "<br>" + myArray[i].letter; new_info = myArray[i].link; (function(new_info) { $(this).click(function(){ //this - refers to A or B or C $('#box2').text(new_info); }); }).call(this, myArray[i])}$('#box1').append(list);
添加回答
举报
0/150
提交
取消