HTML and CSS Reference
In-Depth Information
$(“p”).mouseleave(function () {
<style type=”text/css” media=”screen”>
p { padding: .5em;}
p.highlighted { background: yellow; }
<p> This is the first paragraph on the page. </p>
<p> This is the second paragraph on the page. </p>
No paragraphs are
highlighted initially.
On this page, I have two paragraphs that have no classes assigned to them by default. I
also have a style sheet that applies a yellow background to any paragraph with the class
highlighted . Most important, I have the following two event handlers:
$(“p”).mouseenter(function () {
$(“p”).mouseleave(function () {
In this example, I use the jQuery mouseenter and mouseleave events to fire events
whenever the user moves their mouse over or away from a paragraph. As you can see in
Figure 16.6, when the user's mouse is over the paragraph, the class highlighted is
applied to it. When the mouse moves away, the class is removed.
Search WWH ::

Custom Search