event attributes of HTML em element
event attributes of HTML em element allow users to initiate some action (as if some script is being executed) against interaction (e.g. clicking by mouse, pressing a key etc).
onclick
onclick attribute of HTML em element initiates some action predefined in a script associated with it, when the user clicks on the content of the element.
Syntax
<em onclick="some_script | calling some script">text content</em>
Example of using onclick 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_onclick(){
alert("Thanks for visiting w3reource.");
}
</script>
</head>
<body>
<p>This is an example of <em onclick="w3r_em_onclick()">HTML em tag.</em></p>
</body>
</html>
Result
View this example in a separate browser window
Example of onclick attribute of em element
ondblclick
ondblclick attribute of HTML em element initiates some action predefined in a script associated with it, when the user double clicks on the content of the element.
Syntax
<em ondblclick="some_script | calling some script">text content</em>
Example of using ondblclick 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_ondblclick(){
alert("Thanks for visiting w3reource.");
}
</script>
</head>
<body>
<p>This is an example of <em ondblclick="w3r_em_ondblclick()">HTML em tag.</em></p>
</body>
</html>
Result
View this example in a separate browser window
Example of ondblclick attribute of em element
onmousedown
onmousedown 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 onmousedown="some_script | calling some script">text content</em>
Example of using onmousedown 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_onmousedown(){
alert("Thanks for visiting w3reource.");
}
</script>
</head>
<body>
<p>This is an example of <em onmousedown="w3r_em_onmousedown()">HTML em tag.</em></p>
</body>
</html>
Result
View this example in a separate browser window
.Example of onmousedown attribute of em element
Continue reading to learn more event attributes of HTML em tag.
Previous: style attribute of HTML em element
Next: event attributes of HTML em 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://www.w3resource.com/html/em/HTML-em-tag-event-attributes.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics