by thebeebs
13. November 2010 07:41
Last week jQuery 1.4.4 was released and I'm glad to tell you that the Microsoft CDN version of jQuery is now available at:
http://ajax.microsoft.com/ajax/jquery/jquery-1.4.4.min.js
JQuery also host their own CDN at http://code.jquery.com/jquery-1.4.4.min.js at the point of writing Google haven’t yet updated their CDN but when they do it’s info will be here.
1.4.4 is is the fourth minor release of jQuery 1.4 and fixes a number of bug and adds a few improvements, they have also added the new fadeToggle method. All the fixes can be found here in the jQuery release notes.
So what is fadeToggle?
For a long time we have been able to toggle slide and class so I guess it makes sense to add this feature to fading as well. Basically you can use it to fade in or out a elements opacity without having to check it’s current visibility.
As with all jQuery effects you can disable the effect globally by using the following code:
Under the covers this sets the duration property to 0.
Using fadeToggle
It’s pretty simple to use. In the example below I added a reference to jQuery 1.4.4 then added a link and an Image with the ID of Teddy. In the onclick event of the link I added some jQuery to select the image object and then call the fadeToggle function.
<!DOCTYPE html>
<head>
<title>fadeToggle</title>
<script src="http://ajax.microsoft.com/ajax/jquery/jquery-1.4.4.min.js" language="javascript"
type="text/javascript"></script>
</head>
<body>
<a href="#" onclick="$('#teddy').fadeToggle()">Show or Hide the teddy </a>
<br />
<img id="teddy" src="images/teddy.jpg" />
</body>
</html>
Show or Hide the teddy
a437a079-4585-4597-b263-24bd68ba9bed|1|5.0
Tags: