i have 4 submit button,
<input type="submit" name="zmianapoz" value="Zmiana Ilości" id="dodaj1" />
<input type="submit" name="usunpoz" value="Usunięto" id="dodaj3" />
<input type="submit" value="Pobranie" id="dodaj2" />
and this is fourth:
<input type="submit" name="submit" value="Aktualizuj">
how can i do that if i press enter key=13 then work button fourth not first on web? i try with function onclick but probably i do something wrong
You should be able to trap the keydown event and trigger it yourself like so:
document.addEventListener("keydown", function(event) { var enter = 13; if (event.keyCode === enter) { event.preventDefault(); document.getElementById("dodaj4").click(); } }); document.getElementById("dodaj4").addEventListener("click", function() { alert("input 4 clicked!"); });
<input type="submit" name="zmianapoz" value="Zmiana Ilości" id="dodaj1" /> <input type="submit" name="usunpoz" value="Usunięto" id="dodaj3" /> <input type="submit" value="Pobranie" id="dodaj2" /> <input type="submit" name="submit" value="Aktualizuj" id="dodaj4">
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.