event attributes of HTML em element completed
onkeypress
onkeypress attribute of HTML em element initiates some action predefined in a script associated with it, when the user presses the key on the element.
Syntax
<em onkeypress="some_script | calling some script">text content</em>
Example of using onkeypress with em element
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML em tag example - HTML tutorial | w3resource</title>
<script type="text/javascript">
function w3r_em_onkeypress(){
alert("Thanks for visiting w3reource.");
}
</script>
</head>
<body>
<p>This is an example of <em onclick="w3r_em_onkeypress()">HTML em tag.</em></p>
</body>
</html>
Result
View this example in a separate browser window
Example of onkeypress attribute of em element
onkeydown
onkeydown attribute of HTML em element initiates some action predefined in a script associated with it, when the user pressed a key and yet to release it, on the element.
Syntax
<em onkeydown="some_script | calling some script">text content</em>
Example of using onkeydown with em element
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML em tag example - HTML tutorial | w3resource</title>
<script type="text/javascript">
function w3r_em_onkeydown(){
alert("Thanks for visiting w3reource.");
}
</script>
</head>
<body>
<p>This is an example of <em onkeydown="w3r_em_onkeydown()">HTML em tag.</em></p>
</body>
</html>
Result
View this example in a separate browser window
Example of onkeydown attribute of em element
onkeyup
onkeyup attribute of HTML em element initiates some action predefined in a script associated with it, when the user presses the mouse button on the content of the element.
Syntax
<em onkeyup="some_script | calling some script">text content</em>
Example of using onkeyup with em element
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML em tag example - HTML tutorial | w3resource</title>
<script type="text/javascript">
function w3r_em_onkeyup(){
alert("Thanks for visiting w3reource.");
}
</script>
</head>
<body>
<p>This is an example of <em onkeyup="w3r_em_onkeyup()">HTML em tag.</em></p>
</body>
</html>
Result
View this example in a separate browser window
Example of onkeyup attribute of em element
Previous: event attributes of HTML em element
Next: HTML strong tag and element
Test your Programming skills with w3resource's quiz.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/html/em/HTML-em-tag-event-attributes-completed.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics