javascript - Element keypress when mouse hovered -


i want make function when input keypressed on disabled element.

$(".example").on("keypress", function(e) {    if (e.keycode == 13) {      alert("enter pressed");    }  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <input class="example" disabled/>

i trying on hover method can't succesfull.

this jsfiddle link: https://jsfiddle.net/vl9emkzl/

edit second fiddle link : https://jsfiddle.net/vl9emkzl/1

use readonly instead of disabled. disabled elements can't emit events.

$(".example").on("keypress", function(e) {    if (e.keycode == 13) {      alert("enter pressed");    }  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>  <input class="example" readonly/>


Comments

Popular posts from this blog

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

transpose - Maple isnt executing function but prints function term -