I have a variable x which counts the number of fields added to a form dynamically. I want to remove a field for which I tried to use the following code. But I can't.
$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $( "div" ).remove( ".org-details\'+(x-1)+\'" );x--;
})
});
I want the output be something like this on runtime.
$( "div" ).remove( ".org-details1" );
Please help.
您应该使用模板文字(注意反引号):
$("div").remove(`.org-details${x-1}`)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.