jQuery fading elements in and out
Posted on September 29, 2011 | No Comments
Fading elements in and out
<html>
<head>
<style>
ul {
margin-left: 20px;
color: blue;
}
li {
cursor: default;
}
span {
color: red;
}
</style>
<script src="jquery-1.4.2.js"></script>
</head>
<h3><font color="red">Hover on any element to see effect</font></h3>
<body>
<ul>
<li>Cake</li>
<li>Pastries</li>
<li class='fade'>Patties</li>
<li class='fade'>Noodles</li>
</ul>
<script>
$("li").hover(function() {
$(this).append($("<span><<< </span>"));
}, function() {
$(this).find("span:last").remove();
});
//li with fade class
$("li.fade").hover(function() {
$(this).fadeOut(100);
$(this).fadeIn(500);
});
</script>
</body>
</html>
Comments
Leave a Reply
You must be logged in to post a comment.
Sameera at LinkedIn
