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}`)x--;afterremoveas--xdecrements and returns the value after decrementing.