javascript 事件绑定问题
人气:0
子页面HTML:
<input type="checkbox" name="check" onclick="CheckedBox(this)" value="a" />
子页面JS:
function CreateIOC(text,value) {
var o = document.createElement("a");
o.id = value;
o.href = "#";
o.className = "c";
o.style.border = "2px solid red";
o.style.width = "250px";
o.style.height = "30px";
o.style.display = "block";
o.innerHTML = "<table><tr><td>" + text + "</td><td><img src='/JavaScripts/Data/close.gif' width='13' height='13'/></td></tr></table>";
o.setAttribute("onclick", "iocClick()");
return o;
}
function iocClick() {
alert('ok');
}
function CheckedBox(box) {
window.parent.document.getElementById("kdks_panel").appendChild(CreateIOC('1','2'));
}
父级HTML:
<div id="kdks_panel"></div>
复制代码 代码如下:
<input type="checkbox" name="check" onclick="CheckedBox(this)" value="a" />
子页面JS:
复制代码 代码如下:
function CreateIOC(text,value) {
var o = document.createElement("a");
o.id = value;
o.href = "#";
o.className = "c";
o.style.border = "2px solid red";
o.style.width = "250px";
o.style.height = "30px";
o.style.display = "block";
o.innerHTML = "<table><tr><td>" + text + "</td><td><img src='/JavaScripts/Data/close.gif' width='13' height='13'/></td></tr></table>";
o.setAttribute("onclick", "iocClick()");
return o;
}
function iocClick() {
alert('ok');
}
function CheckedBox(box) {
window.parent.document.getElementById("kdks_panel").appendChild(CreateIOC('1','2'));
}
父级HTML:
复制代码 代码如下:
<div id="kdks_panel"></div>
加载全部内容