Definition and Usage..
The onkeyup event occurs when the user releases a key (on the keyboard).
Syntax :
In HTML: <element onkeyup="myScript">
In JavaScript: object.onkeyup = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("keyup", myScript);
CODING:The onkeyup event occurs when the user releases a key (on the keyboard).
Syntax :
In HTML: <element onkeyup="myScript">
In JavaScript: object.onkeyup = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("keyup", myScript);
<!DOCTYPE html>
<html>
<body>
Enter your name: <input type="text" id="fname" onkeyup="onkeyup1()"><br>
<p id="p">Your name is..</p>
<script>
function onkeyup1() {
var x = document.getElementById("fname");
x.value = x.value.toUpperCase();
}
document.getElementById("fname").onkeyup = function() {onkeyup2()};
function onkeyup2() {
document.getElementById("p").innerHTML=document.getElementById("fname").value.toUpperCase();
}
document.getElementById("fname").addEventListener("keyup", myFunction);
function myFunction() {
document.getElementById("fname").style.color="lightgreen";
}
</script>
</body>
</html>
<html>
<body>
Enter your name: <input type="text" id="fname" onkeyup="onkeyup1()"><br>
<p id="p">Your name is..</p>
<script>
function onkeyup1() {
var x = document.getElementById("fname");
x.value = x.value.toUpperCase();
}
document.getElementById("fname").onkeyup = function() {onkeyup2()};
function onkeyup2() {
document.getElementById("p").innerHTML=document.getElementById("fname").value.toUpperCase();
}
document.getElementById("fname").addEventListener("keyup", myFunction);
function myFunction() {
document.getElementById("fname").style.color="lightgreen";
}
</script>
</body>
</html>
Comments
Post a Comment