1.页面动态加载,并且动态加载后的元素仍然有事件
function fun(e){
var cc = e.srcElement ? e.srcElement : e.target;
//alert(cc.tagName);
alert(cc.value);
}
function loadSsid(){
var addDiv = document.getElementById('ssidlist');
for(var j =0; j < ssidarray.length; j ++){
var br = document.createElement("br");
addDiv.appendChild(br);
var fileObj = document.createElement("input");
fileObj.setAttribute('id',ssidarray[j]);
fileObj.setAttribute('value',ssidarray[j]);
fileObj.setAttribute('type',"text");
if(fileObj.addEventListener)
{
fileObj.addEventListener('click',fun);
}
else if(fileObj.attachEvent)
{
fileObj.attachEvent('onclick',fun);
}
addDiv.appendChild(fileObj);
}
}
2.在页面加载后,再自动调用某function 放在body的onLoad里面
3.console.log()打印信息