Javascript code is deleting row on hit enter and button click
Below code is working deleting row on button click but even if i am entering text in input field and if i press ENTER it is deleting the row also. I am using this for multiple fields generated dynamically.
How can i avoid the deletion of row on pressing enter?
Javascript
//===== delete the form field row
$("body").on("click", ".remove_node_btn_frm_field", function () {
$(this).closest(".form_field_outer_row").remove();
});
>Solution :
A HTML button element’s default type is submit, a side effect of this is that is also captures the enter key.
If this button is not meant to submit a form, you will want to make sure the type is set to button.
<button type="button">