日期:2014-05-16 浏览次数:20487 次
以下代码为何在第一次输入的时候是无效的,要输入一次之后再次输入才有效果 [code=HTML]<html> <head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title></title> <script src="js/jquery-1.4.2.min.js" type="text/javascript"></script> <script type="text/javascript"> function ShowImage(obj,cid) { jQuery("#"+obj).change(function(){ var allvalue= $(this).val(); $("."+cid).each(function(i){$(this).val(allvalue);}); }); } </script> </head> <body> <input type="text" class="a" value="1" readonly /><br> <input type="text" class="a" value="2" readonly /><br> <input type="text" class="a" value="3" readonly /><br> <input type="text" class="a" value="4" readonly /><br> <input type="text" class="a" value="5" readonly /><br> <input type="text" class="b" value="6" readonly /><br> <input type="text" class="b" value="7" readonly /><br> <input type="text" class="b" value="8" readonly /><br> 输入a:<input id="a1" type="text" value="a1" onkeydown="ShowImage('a1','a')"><br>输入b:<input id="b1" type="text" value="b" onkeydown="ShowImage('b1','b')"> </body> </html>
<html> <head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <title></title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> function ShowImage(obj,cid) { jQuery("#"+obj).keyup(function(){ var allvalue= $(this).val(); $("."+cid).each(function(i){$(this).val(allvalue);}); }); } </script> </head> <body> <input type="text" class="a" value="1" readonly /><br> <input type="text" class="a" value="2" readonly /><br> <input type="text" class="a" value="3" readonly /><br> <input type="text" class="a" value="4" readonly /><br> <input type="text" class="a" value="5" readonly /><br> <input type="text" class="b" value="6" readonly /><br> <input type="text" class="b" value="7" readonly /><br> <input type="text" class="b" value="8" readonly /><br> 输入a:<input id="a1" type="text" value="a1" onkeydown="ShowImage('a1','a')"><br>输入b:<input id="b1" type="text" value="b" onkeydown="ShowImage('b1','b')"> </body> </html>