JS动态生成元素鼠标响应方法live()函数
jQuery在动态生成HTML元素后,如果该元素集合中有鼠标点击CLICK事件。
这时点击无响应,需要用到.live()方法使生成的动态元素依然保持页面装载后的效果,使鼠标点击事件生效。
jQuery(document).ready(function(){
var contentTR=$('.info tr:eq(0)').html();
var e=0;
$('.addrow').click(function(){
e=e+1;
$(".info .addrow").parent().parent().before('' + contentTR + ' ');
$(".info tr:eq("+e+")").find("input:eq(0)").attr("name","a"+e);
$(".info tr:eq("+e+")").find("input:eq(1)").attr("name","b"+e);
$(".info tr:eq("+e+")").find("select:eq(0)").attr("name","c"+e);
$(".info tr:eq("+e+")").find("input:eq(2)").attr("name","d"+e);
$(".info tr:eq("+e+")").find("input:eq(3)").attr("name","f"+e);
});
$('.del').live('click',function(){
$(this).parent().parent().remove();
});
});
SQL ROW_NUMBER() 排序函数详解 wordpress如何制作自定义搜索框和结果页面
Your point of view caught my eye and was very interesting. Thanks. I have a question for you.
收藏好文章。谢谢分享
爆破测振仪-中科测控-http://www.zkck.com