Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make keypress inline in html element to catch enter

If I have html element like this

<input type = "text" onkeypress="if(this.keyCode == 13){alert()}" />

Not work, Please advice

like image 323
Fadly Dzil Avatar asked Nov 10 '16 06:11

Fadly Dzil


Video Answer


1 Answers

You can try like this

<input type = "text" onkeypress="javascript: if(event.keyCode == 13) alert();" />
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
like image 150
Bharat Avatar answered Oct 03 '22 22:10

Bharat