【发布时间】:2011-02-02 10:34:53
【问题描述】:
代码:
DeCheBX = $('MyDiv').insert(new Element('input', { 'type': 'checkbox', 'id': "Img" + obj[i].Nam, 'value': obj[i].IM, 'onClick': SayHi(id) }));
document.body.appendChild(DeCheBX);
DeImg = $('MyDiv').insert(new Element('img', { 'id': "Imgx" + obj[i].Nam, 'src': obj[i].IM }));
document.body.appendChild(DeImg);
}
SayHi = function(x) {
try {
if($('x').checked == true)
{
alert("press" + x);
}
}
catch (e) {
alert("error");
}
};
【问题讨论】:
-
格式化并注释您的代码,以便我们知道它应该做什么。
-
我想像当我点击复选框时那样调用它应该调用函数 obj 是我在其中调用的 json 字符串。x 将是我点击的复选框 id 的值。DecheckBx跨度>
标签: javascript javascript-framework