javascriptÎÊÌâ
HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ÎÞ±êÌâÎĵµ</title>
<style type="text/css">
li{border:1px solid #f30;list-style:none;margin:3px; cursor:pointer}
</style>
</head>
<body>
<ul id="show">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</body>
<script language="javascript">
function show(){
var a=document.getElementById("show").getElementsByTagName("li");
for(var i=0;i<a.length;i++){
a[i].onclick=function(){
alert(i)
}
}
}
show()
</script>
</html>
µã»÷"li"µÄʱºòÎÒÔ±¾´òËãÊÇÈÃËü·Ö±ðµ¯³öiµÄÖµ(1,2,3,4)£¬¿ÉÊÇËüÀÏÊǵ¯³ö4,Ò²¾ÍÊÇa.lengthµÄÖµ,ÕâÊÇΪʲô°¡£¿
ÒòΪ i ×îºóµÄÖµÊÇ 4
¸Ä³ÉÏÂÃæµÄ¾Í¶ÔÁË
a[i].onclick = new Function("alert(" + i + ")");
Â¥Ö÷ÕâÑù¾Í¿ÉÒÔÁË
JScript code
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHig
Ïà¹ØÎÊ´ð£º
ÓÃjavascript½«Êý¾Ýµ¼³öµ½Îı¾Îļþ(txt)ÖÐ..
Ê×ÏȼÙÉèÒѾÓÐÁËÐèҪдÈëµÄÎı¾ÄÚÈÝ var txtContent ="ÐèҪдÈëµÄÄÚÈÝ";
ÏÖÔÚÐèÒªÓÃjavascript½«ÄÚÈÝдÈëtxtÎļþ(Õâ¸ötxtÎļþ²»´æÔÚ,ÐèÒª´´½¨)ÖÐ,È»ºóдºÃÖ ......
ÎÒÊÖ±ßÓÐcsdnÂÛ̳µ¯³öÐÅÏ¢´°¿ÚµÄ´úÂë(¿ÉÒÔ´Óhttp://www.codefans.netÏÂÔØ)£¬µ«ËüÏÔʾµÄÖ»Êǹ̶¨µÄÐÅÏ¢£¬ÏÖÔÚÏë¸ÄÔìÒ»ÏÂÒÔ±ãÄÜͨ¹ýºǫ́µ÷ÓÃSql Server 2000Êý¾Ý¿â×Ô¶¯½«Êý¾Ý±íÖеÄÐÅÏ¢×÷Ϊµ¯³ö´°¿ÚÏÔʾµÄÐÅÏ¢¡£csdnÂÛ ......
ÀýÈç:
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="table">
<tr>
& ......
<asp:datagrid id="DataGrid1" runat="server" Width="632px" AutoGenerateColumns="False" OnItemDataBound="DataGrid1_ItemDataBound">
......