87,992
社区成员
发帖
与我相关
我的任务
分享
items2 = oDoc.selectNodes("//CLASSNAME/Table/pcl2_id");
var itemsLength=items1.length;
for(i=0;i<itemsLength;i++)
{
var newOption = document.createElement("li");
newOption.setAttribute('onclick',function (){load2(items2[i].text);})
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script>
var array=[1,2,3,4,5,6];
function testvalue(val)
{
alert(val);
}
function add(){
for(i=0,len=array.length;i<len;i++)
{
var newOption = document.createElement("li");
newOption.innerHTML=i+1;
newOption.onclick=function (val){ return function(){testvalue(val);}}(array[i])
document.getElementById('div').appendChild(newOption);
}
}
</script>
</HEAD>
<BODY>
<input type='button' value='click me' onclick='add()' />
<div id='div'></div>
</BODY>
</HTML>