Learn Dreamweaver

Use Jquery to Change CSS Class

by monstertutor

Jquery is really a powerful script. You can use this to add or remove class name of a CSS declaration.

To do this, you need to have the jquery script first. The code may vary depending on the latest version.

<script type="text/javascript" 
src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script>

After this, you can insert the following code:

<script type="text/javascript">
$(document).ready(function(){	
	$('.blue')..removeClass('blue').addClass('green');
});
</script>

You now have replaced the class name “blue” with “green”

Related posts:

How to show form input values onblur and hide onfocus
Favicon HTML Code
How to Make Horizontal Navigation in CSS and HTML
Query Post Terms by Taxonomy and Post Type

Recommended Web Design Books!


Category: CSS, Jquery
Tags: cheat sheet, coding


Special Offer! $8.99 .COMs or .Nets now at GoDaddy!