如何在ecshop中给js动态生成的元素绑定事件,ecshop中transport.js与jquery的delegate方法冲突?如何解决

发布时间:2019-08-03 01:28:04

如何在ecshop中给js动态生成的元素绑定事件,ecshop中transport.js与jquery的delegate方法冲突?如何解决

推荐回答

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>checkbox</title> <script src="js/jquery-1.3.2.js" type="text/javascript"></script> <script src="js/1.js" type="text/javascript"></script> </head> <body> <table id="table1"> <tr> <td><input type="checkbox" value="1"/>1</td> <td id="k_1"><input type="text" name="student" id="s_1" readonly="true"/></td> </tr> <tr> <td><input type="checkbox" value="2"/>2</td> <td id="k_2"><input type="text" name="student" id="s_2" readonly="true"/></td> </tr> <tr> <td><input type="checkbox" value="3"/>3</td> <td id="k_3"><input type="text" name="student" id="s_3" readonly="true"/></td> </tr> <tr> <td><input type="checkbox" value="4"/>4</td> <td id="k_4"><input type="text" name="student" id="s_4" readonly="true"/></td> </tr> </table> </body> </html> ------------------------------------------------------------- $(document).ready(function() { $("td[id^='k_']").hide(); var check = $(":checkbox"); //得到所有被选中的checkbox var actor_config; //定义变量 check.each(function(i){ actor_config = $(this); actor_config.click( function(){ if($(this).attr("checked")==true){ $("#k_"+$(this).val()).show(); }else{ $("#k_"+$(this).val()).hide(); } } ); }); });
以上问题属网友观点,不代表本站立场,仅供参考!