Javascript 从jquery中的列表中删除项不工作
以前有人问过这个问题,但我无法找到解决方案 我有一个HTML和jquery代码,它添加了如下行:-Javascript 从jquery中的列表中删除项不工作,javascript,jquery,html,Javascript,Jquery,Html,以前有人问过这个问题,但我无法找到解决方案 我有一个HTML和jquery代码,它添加了如下行:- $(文档).ready(函数(){ window.VendorDetail='@Url.Action(“GetQuoteVendorDetail”,“Technical”); window.SaveItemDetails='@Url.Action(“SaveItemDetails”,“Technical”); $(“#divQuoteDetails”).hide(); //1.添加新行 $(“#
$(文档).ready(函数(){
window.VendorDetail='@Url.Action(“GetQuoteVendorDetail”,“Technical”);
window.SaveItemDetails='@Url.Action(“SaveItemDetails”,“Technical”);
$(“#divQuoteDetails”).hide();
//1.添加新行
$(“#添加新”)。单击(函数(e){
e、 预防默认值();
var$tableBody=$(“#可抽签”);
var$trLast=$tableBody.find(“tr:last”);
var$trNew=$trLast.clone();
变量后缀=$trNew.find(':input:first').attr('name').match(/\d+/);
$trNew.find(“td:last”).html(“”);
$.each($trNew.find(':input'),函数(i,val){
//更名
var oldN=$(this.attr('name');
var newN=oldN.replace('['+后缀+']','['+(parseInt(后缀)+1)+']');
$(this.attr('name',newN));
//替换值
var type=$(this.attr('type');
if(type.toLowerCase()=“text”){
$(this.attr('value','');
}
//如果有其他类型,则替换为默认值
$(this).removeClass(“输入验证错误”);
});
$trLast.after($trNew);
//重新分配验证
//变量形式=$(“形式”)
//.removeData(“验证器”)
//.removeData(“不引人注目的验证”);
//$.validator.unobtrusive.parse(表单);
});
//2.移除
$('.remove')。在(“单击”,“a”,函数(e)上{
调试器;
e、 预防默认值();
$(this.parent().parent().remove();
});
});代码>
批号
批号
批量
@foreach(ViewBag.LotTable中的var项)
{
}
1.当DOM元素被呈现时,您应该通过将事件移除
一次单击到内部$(“#添加新”)。单击下面的来收听事件
//$.validator.unobtrusive.parse(form);
// 2. Remove
$('.remove').on("click", function (e) {
console.log("Removed");
$(this).parent().parent().remove();
});
阅读以下文章以更好地理解
2.您已经收听了。请删除元素,这样您就无需再次收听(“单击”、“a”和)
$(文档).ready(函数(){
window.VendorDetail='@Url.Action(“GetQuoteVendorDetail”,“Technical”);
window.SaveItemDetails='@Url.Action(“SaveItemDetails”,“Technical”);
$(“#divQuoteDetails”).hide();
//1.添加新行
$(“#添加新”)。单击(函数(e){
e、 预防默认值();
var$tableBody=$(“#可抽签”);
var$trLast=$tableBody.find(“tr:last”);
var$trNew=$trLast.clone();
变量后缀=$trNew.find(':input:first').attr('name').match(/\d+/);
$trNew.find(“td:last”).html(“”);
$.each($trNew.find(':input'),函数(i,val){
//更名
var oldN=$(this.attr('name');
var newN=oldN.replace('['+后缀+']','['+(parseInt(后缀)+1)+']');
$(this.attr('name',newN));
//替换值
var type=$(this.attr('type');
if(type.toLowerCase()=“text”){
$(this.attr('value','');
}
//如果有其他类型,则替换为默认值
$(this).removeClass(“输入验证错误”);
});
$trLast.after($trNew);
//重新分配验证
//变量形式=$(“形式”)
//.removeData(“验证器”)
//.removeData(“不引人注目的验证”);
//$.validator.unobtrusive.parse(表单);
//2.移除
$('.remove')。打开(“单击”,函数(e){
控制台日志(“删除”);
$(this.parent().parent().remove();
});
});
});
批号
批号
批量
@foreach(ViewBag.LotTable中的var项)
{
}
1.当DOM元素被呈现时,您应该通过将事件移除
一次单击到内部$(“#添加新”)。单击下面的来收听事件
//$.validator.unobtrusive.parse(form);
// 2. Remove
$('.remove').on("click", function (e) {
console.log("Removed");
$(this).parent().parent().remove();
});
阅读以下文章以更好地理解
2.您已经收听了。请删除元素,这样您就无需再次收听(“单击”、“a”和)
$(文档).ready(函数(){
window.VendorDetail='@Url.Action(
$(staticAncestors).on(eventName, dynamicChild, function() {});
// 2. Remove
$('#lotTable').on("click", '.remove', function (e) {
$(this).parent().parent().remove();
});