<html>
<head>
<title> New Document </title>
</head> <body>
<script type="text/javascript">
alert("zhegjkglkjasg");
for(int i=0;i<6;i++)
{
alert("fhkl");
document.write("<input type="button" value="button" onclick="Button(i)"/>");
}
function Button(int i)
{
alert(""按钮"+i"");
}
</script> <p> hlkhdlkshfdsahgd</p>
<input type="button" value="button" onclick="Button(1)"/>
</body>
</html>为什么javascript里面的东西完全没有用的,新手求救~勿喷~
<head>
<title> New Document </title>
</head> <body>
<script type="text/javascript">
alert("zhegjkglkjasg");
for(int i=0;i<6;i++)
{
alert("fhkl");
document.write("<input type="button" value="button" onclick="Button(i)"/>");
}
function Button(int i)
{
alert(""按钮"+i"");
}
</script> <p> hlkhdlkshfdsahgd</p>
<input type="button" value="button" onclick="Button(1)"/>
</body>
</html>为什么javascript里面的东西完全没有用的,新手求救~勿喷~
<head>
<title> New Document </title>
</head> <body>
<script type="text/javascript">
alert("zhegjkglkjasg");
for(var i=0;i<6;i++)// int ,靠~~
{
alert("fhkl");
document.write("<input type=\"button\" value=\"button\" onclick=\"Button("+i+")\"/>");
//双引号不要和双引号一起用,你如果想要一起用,把里面的用转义字符处理,或者直接使用单引号
//因为上式的i是变量,所以~~~这个真是难讲,你这个都还不会处理,还是要多看看js基础啊
}
function Button(i)//int不是js里面的类型,真是蛋疼了~~可以不做定义的
{
alert("按钮="+i);
//这个地方,算是个什么错误啊~~~~~~~~
}
</script> <p> hlkhdlkshfdsahgd</p>
<input type="button" value="button" onclick="Button(1)"/>
</body>
</html>楼主,你故意的吧,让人看得蛋疼了~~你这好像完全还把js和C混着嘛~~
js不是强类型的语言,定义变量通通类似于:var a=0,b='1',c=new Array(),d=[],e={}
<head>
<title> New Document </title>
</head> <body>
<script type="text/javascript">
// alert("zhegjkglkjasg");
for(var i=0;i<6;i++)
{
// alert("fhkl");
(function(i){
document.writeln("<input type='button' value='button_"+i+"' onclick='Button("+i+");'/>");
})(i)
}
function Button(i)
{
alert("按钮"+i);
}
</script> <p> hlkhdlkshfdsahgd</p>
<input type="button" value="button" onclick="Button(1)"/>
</body>大哥,你这代码写的...
</html>