首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

为啥javascript里面的函数没反应,没调用到吗

2012-10-06 
为什么javascript里面的函数没反应,没调用到吗?htmlheadtitle New Document /title/headbody

为什么javascript里面的函数没反应,没调用到吗?
<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里面的东西完全没有用的,新手求救~勿喷~

[解决办法]

JScript code
<html>  <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> 

热点排行