02.06.2013 Views

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

jQuery 1.4 Animation Techniques - Index of

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[ 95 ]<br />

Chapter 4<br />

3. Save this file as slideFlicker.css, and add a link to the file from the <strong>of</strong><br />

slideFlicker.html (directly after the link to fadeIn.css).<br />

4. Finally, update the second element at the bottom <strong>of</strong> slideFlicker.<br />

html so that it appears as follows (new code shown in bold):<br />

var ul = $("nav ul");<br />

ul.removeClass("purecss");<br />

ul.find("a").each(function(){<br />

if (!$(this).closest(".subnav").length) {<br />

var a = $(this);<br />

a.append("" + a.text() + "");<br />

}<br />

});<br />

ul.find("a").hover(function() {<br />

$(this).find("span").fadeIn("slow");<br />

}, function() {<br />

$(this).find("span").hide();<br />

});<br />

$(".subnav", ul).parent().mouseenter(function() {<br />

$(this).find(".subnav").stop(true, true).slideDown("fast");<br />

});<br />

$(".subnav", ul).parent().mouseleave(function() {<br />

$(this).find(".subnav").stop(true, true).slideUp("fast");<br />

});<br />

What just happened?<br />

All we've done to the underlying HTML is added a couple <strong>of</strong> submenus to two <strong>of</strong> the top level<br />

list items in the . One <strong>of</strong> the submenus is a split menu made up <strong>of</strong> two elements<br />

inside a , the other is a single menu built from a standard .<br />

We've also added some new styling, mostly to carry on the theme from the original example.<br />

Some <strong>of</strong> the CSS is used to override previous rules set in the original stylesheet. Mostly the<br />

styling is purely for aesthetics, and we use a lot <strong>of</strong> CSS3 rounded-corner styling, which will<br />

not be apparent in all browsers.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!