6
<!DOCTYPE html>
<html lang="pt">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</style>
</head>
<body>
<div style="background:#98bf21;height:100px;width:100px;position:absolute;"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(document).keypress(function(x){
if(x.wich == 13 || x.keyCode == 13){
var div = $("div");
div.animate({height: '300px', opacity: '0.4'}, "slow");
div.animate({width: '300px', opacity: '0.8'}, "slow");
div.animate({height: '100px', opacity: '0.4'}, "slow");
div.animate({width: '100px', opacity: '0.8'}, "slow");
}
});
});
</script>
</body>
</html>
Guys, this code is only working with enter key (keycode 13). If I switch to another key, like 39 for example, and press, it does not perform the action.
ball show man, thank you !
– blackbird312
Why not
keypress
?– relaxeaza
@Rafaelmafra, edited by :)
– Samir Braga