标签:style blog http io color ar java sp for
1 <!DOCTYPE html> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <title>通过ID获取值</title> 5 6 <script type="text/javascript"> 7 function intevent() 8 { 9 //这个初始化是为每一个input的按钮加入了onclick事件 10 var inputs = document.getElementsByTagName("input"); 11 for(var i=0;i<inputs.length;i++) 12 { 13 var input = inputs[i]; 14 input.onclick = btnclick; 15 16 } 17 } 18 function btnclick() 19 { 20 var inputs = document.getElementsByTagName("input"); 21 for (var i = 0; i < inputs.length; i++) { 22 var input = inputs[i]; 23 if(input==window.event.srcElement) 24 { 25 input.value = "呜呜"; 26 } 27 28 else 29 { 30 input.value = ‘laugh‘; 31 } 32 33 } 34 } 35 </script> 36 </head> 37 <body onload="intevent()"> 38 <input type="button" value="laugh" /> 39 <input type="button" value="laugh" /> 40 <input type="button" value="laugh" /> 41 <input type="button" value="laugh" /> 42 <input type="button" value="laugh" /> 43 <input type="button" value="laugh" /> 44 </body> 45 </html>
标签:style blog http io color ar java sp for
原文地址:http://www.cnblogs.com/sytu/p/4086981.html