Relax Breath of Solution.Community tech blog of Sameera Thilakasiri - Consultant UI, UX, RWD Specialist/ Interactive Designer

Just I wanted.. Do you?…

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>

Author
Sameera Thilakasiri By Sameera Thilakasiri
,is a front-end developer based in Colombo, is a blogger and a lifestyle photographer.
Follow him Twitter and Google+. Check out him.

Comments

Leave a Reply

You must be logged in to post a comment.