jQuery: Right click to toggle background color
jQuery Fundamental - II : Exercise-62
Using jQuery right click to toggle background color.
Sample solution :
HTML Code :
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Using jQuery right click to toggle background color.</title>
</head>
<body>
<div></div>
<p>Right click the block</p>
</body>
</html>
CSS Code :
div {
background: red;
color: white;
height: 150px;
width: 150px;
}
div.contextmenu {
background: green;
color: black;
}
See the Pen jquery-fundamental-exercise-62 by w3resource (@w3resource) on CodePen.
Contribute your code and comments through Disqus.
Previous: Display a message when the contextmenu event is triggered on the paragraph elements.
Next: Get the background color of a clicked division.
What is the difficulty level of this exercise?
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/jquery-exercises/2/jquery-fundamental-exercise-62.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics