Answer the question
In order to leave comments, you need to log in
Why is another event fired?
Why, in the example, does another event fire? How to turn it off?
Open the console, stand on input and press Enter.
In the console it is not written <button>Добавить</button>
, but there was no click on the "Add" button.
<form action="" onsubmit="return false">
<table>
<thead><tr><td>Наименование</td><td>Цена</td></tr></thead>
<tbody>
<tr>
<td><input type="text"></td>
<td><input type="text"></td>
</tr>
</tbody>
</table>
<button>Добавить</button>
</form>
window.addEventListener('click', selected, false);
function selected(e) {
e.preventDefault();
e.stopImmediatePropagation();
if ( e.target.tagName == 'BUTTON' ) console.log(e.target);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question