I have to add and remove an input field in div with id "add", So the following code is not working.
<div id="add">
</div>
<button id="add-el">Add</button>
<button id="add-el">Remove</button>
$("#add-el").on("click", funtion () {
var input = $("<input class=\"some-class\" type=\"email\" name=\"email\"
required=\"\" placeholder=\"Enter your address\" autocomplete=\"off\">");
$("#add").append(input);
});
$("#remove-el").on("click", funtion () {
$("#add").remove(input);
});
inputvariable inside theclickfunction of the#remove-el.inputis a local variable of the#add-el clickfunction.