Attenuation between two classes in jquery
I want to be able to fade this class
<h2 class="care-home-fees"><a title="Care Home Fees" href="#">Text</a></h2>
and fade in this
<h2 class="care-home-fees-over"><a title="Care Home Fees" href="#">Text</a></h2>
Please note that there are two separate images.
Here is my current markup which doesn't seem to work
$(document).ready(function(){ $("h2.care-home-fees").hover( function () { $(this).addClass("care-home-fees-over"); }, function () { $(this).removeClass("care-home-fees"); } ); });
and a button printed before any change
<h2 class="care-home-fees"><a title="Care Home Fees" href="#">Text</a></h2>
+2
Andy
source share4 answers
You might want .animate()
instead of .addClass()
or .removeClass()
.
What do you want to do with CSS classes in the jQuery user interface?
+2
Daniel A. White
source sharefirst you need to download jquery i jquery-1.3.2.min.js , but if you want the final release of jQuery 1.4.1
change <h2 class="care-home-fees"><a title="Care Home Fees" href="#">Text</a></h2>
to
<h2 class="care-home-fees"><a id="j" title="Care Home Fees" href="#">Text</a></h2>
you need to add jquery file to your html..a i added it below ::
//this is the start of the head <head runat="server"> <title></title> // i added jquery-1.3.2.min.js file here <script src="jquery-1.3.2.min.js" type="text/javascript"></script> <script> $("h2").click(function () { $(document.getElementById('j')).fadeOut("slow"); $("a:hidden:first").fadeIn("slow"); }); </script> //this is the end of the head </head>
Hope this works.
0
jjj
source share $(document).ready(function(){ $('#wm').hover(function(){ $('#wm .bld').stop().fadeTo(300, 0); }, function(){ $('#wm .bld').stop().fadeTo(300, 1); }); $('#ch').hover(function(){ $('#ch .bld').stop().fadeTo(300, 0); }, function(){ $('#ch .bld').stop().fadeTo(300, 1); }); });
0
Andy
source share