jquery click事件 添加html标签后 再次点击无反应

wulinzhijie wulinzhijie 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
想做一个追加input框的功能,代码如下

html代码:
<div class='xhdz'><input type='text' name='xhmc[]' style='width:100px;margin-right:10px;' value='' /><input type='text' name='xhdz[]' class='intxt' value='' /><a href='javascript:void(0)' id='addone'>添加一条</a></div>

js代码:
$(document).ready(function(){
$('#addone').on('click', function(){
var str = "<div class='xhdz'><input type='text' name='xhmc[]' style='width:100px;margin-right:10px;' value='' /><input type='text' name='xhdz[]' class='intxt' value='' /><a href='javascript:void(0)' id='addone'>添加一条</a><a href='javascript:void(0)' class='delone''>删除</a></div>";
$(this).parent().after(str);

$('.delone').click(function(){
$(this).parent().remove();
});
});
});

点击html代码部分的“添加一条”可以添加,但是jquery追加的部分再次点击“添加一条” 就没办法添加了,求大神指点
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
wulinzhijie
JavaScript 87,984 成员 224,681 内容