<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jc-designs.net &#187; jQuery</title>
	<atom:link href="http://jc-designs.net/blog/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://jc-designs.net/blog</link>
	<description>jc-designs blog</description>
	<lastBuildDate>Mon, 21 May 2012 19:32:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>jQuery Mobile Review</title>
		<link>http://jc-designs.net/blog/2011/07/jquery-mobile-review/</link>
		<comments>http://jc-designs.net/blog/2011/07/jquery-mobile-review/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 03:42:47 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Product Reviews]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=970</guid>
		<description><![CDATA[Great things come in small packages A project I&#8217;m working on had me looking into how to create a nice looking mobile site. Two very popular frameworks came to mind: jQuery Mobile, and Sencha Touch. The back-end guy I&#8217;m working with on this project recommended Sencha Touch, so I took a look at that first. [...]]]></description>
			<content:encoded><![CDATA[<h3>Great things come in small packages</h3>
<p>A project I&#8217;m working on had me looking into how to create a nice looking mobile site. Two very popular frameworks came to mind: <a href="http://jquerymobile.com/">jQuery Mobile</a>, and <a href="http://www.sencha.com/products/touch/">Sencha Touch</a>. The back-end guy I&#8217;m working with on this project recommended Sencha Touch, so I took a look at that first. Let me just say that if you haven&#8217;t worked with Ext.js and it&#8217;s panel component, or are not even familiar with that library, you are going to have one hell of a time. It is not all that easy to use, and the limited amount of tutorials on how to use it suck beyond belief. After a couple of hours fiddling with it, I decided to say screw it, and went over to jQuery Mobile. The difference? I got a site up and running in roughly a half hour with no problems themeing. jQuery Mobile wins in ease of use hands down.</p>
<p>This isn&#8217;t to say that Sencha Touch is bad, because it sure looks good,  but it isn&#8217;t as intuitive as Mobile. This isn&#8217;t really about Touch though&#8230;it&#8217;s about Mobile. So let&#8217;s get into it!</p>
<div class="center"><img src="http://www.jc-designs.net/newimages/blogImages/jqueryMobile.png" alt="jQuery Mobile logo" /></div>
<p><span id="more-970"></span></p>
<h3>Pages, nav bars, and buttons &#8211; this stuff is easy!</h3>
<p>Not just those specifically, but everything in general. Pages though, couldn&#8217;t be any more simple because you can do it on one layout. Each different type of section is identified by the attribute &#8216;data-role&#8217;. A page has a data-role of page, a nav bar has a role of nav, footer has a role of footer, header &#8211; header, and it goes on from there. You could almost guess at most of them. So let&#8217;s say you have a mobile page, and you want a header, a nav bar, the content section, and a footer. Check out the simplicity of how you would write this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;div data-role=&quot;page&quot; id=&quot;homePage&quot;&gt;
&nbsp;
	&lt;div data-role=&quot;header&quot;&gt;
		&lt;h1&gt;Home&lt;/h1&gt;
	&lt;/div&gt;
&nbsp;
        &lt;div data-role=&quot;navbar&quot;&gt;
		&lt;ul&gt;
			&lt;li&gt;&lt;a href=&quot;#homePage&quot; class=&quot;ui-btn-active&quot;&gt;Home&lt;/a&gt;&lt;/li&gt;
			&lt;li&gt;&lt;a href=&quot;#about&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
&nbsp;
	&lt;div data-role=&quot;content&quot;&gt;	
		&lt;p&gt;Any idiot with an HTML editor can do this!&lt;/p&gt;	
	&lt;/div&gt;
&nbsp;
	&lt;div data-role=&quot;footer&quot;&gt;
		&lt;h4&gt;All your footer crap goes here. Like social icons that no one cares about.&lt;/h4&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p>For the second page (about in the above example) you would just copy the above html, and change the id of the page dive to &#8216;about&#8217;, and switch the &#8216;ui-btn-active&#8217; class to the &#8216;about&#8217; link in the nav, and you are good to go. Want more pages? Keep doing that. That is what makes this framework so nice. I don&#8217;t have to think about what I am doing. How about buttons? Piece of cake!</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;a href=&quot;#contact&quot; data-role=&quot;button&quot;&gt;Contact us&lt;/a&gt;
&lt;a href=&quot;#pricing&quot; data-role=&quot;button&quot;&gt;Pricing&lt;/a&gt;
&lt;a href=&quot;#services&quot; data-role=&quot;button&quot;&gt;services&lt;/a&gt;</pre></div></div>

<p>Or a list:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;h1&gt;Favorite Movies&lt;/h1&gt;
&lt;ul data-role=&quot;listview&quot; data-theme=&quot;d&quot;&gt;
	&lt;li&gt;&lt;a href=&quot;#a&quot;&gt;Goonies&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#b&quot;&gt;Better Off Dead&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;#c&quot;&gt;Interview with the Vampire&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></div></div>

<h3>Theming jQuery Mobile</h3>
<p>Theming also couldn&#8217;t get any better. There are five basic theme swatches, which is what the framework calls them. They are lettered a, b, c, d, and e. Certain data-roles default to specific swatches, like header and footer, which default to &#8216;a&#8217;. Others default to c. There is a hierarchy on how something defaults, but you don&#8217;t really care about this crap because you are going to style your own in any case.</p>
<p>Well besides adding the necessary script to get jQuery Mobile to work, there is also a CSS file you will link to. All of the required styles are in there. So let&#8217;s say you want your header to use swatch &#8216;b&#8217; (which is blue), you would just have to add the data-theme attribute with the correct letter, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;div data-role=&quot;header&quot; data-theme=&quot;d&quot;&gt;
     &lt;h1&gt;Home&lt;/h1&gt;
&lt;/div&gt;</pre></div></div>

<p>Your header would now have the blue color with white text. But no one is going to use the that blue color, so you go into the style sheet, and find the class and change the color. You could create a whole new swatch theme by copying the necessary styles, and changing the letters within the class names to &#8216;f&#8217;. Be careful though because any button that is placed within a bar, such as the header, will automatically be assigned a swatch letter that matches its parent bar.</p>
<h3>jQuery Mobile for the win!</h3>
<p>My main point in showing you the things that I did above is that the entire framework is easy as hell to use, from basic html to methods for page transitions, to touch events. The documentation is really easy to read, gets to the point quickly, and gives great examples. This is one of the major reasons why I think Sencha Touch will be the number two framework. Anyone can create a nice looking mobile page with jQuery mobile, and get it done quickly.</p>
<p>This doesn&#8217;t mean that the framework only does simple things. It is up to you to use it and do some very cool stuff with it. I also just touched on the basics, so be aware that there are things you have to look out for. An example being that anchor tag linking doesn&#8217;t work because Mobile uses the hash tag to identify pages. Point being, go and actually read the documentation on each part you are working on so that you don&#8217;t run into problems later.</p>
<p>For the brief time I have used jQuery Mobile, I am already a huge fan.</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=970" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/07/jquery-mobile-review/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Build a Horizontal jQuery Accordion</title>
		<link>http://jc-designs.net/blog/2011/07/how-to-build-a-horizontal-jquery-accordion/</link>
		<comments>http://jc-designs.net/blog/2011/07/how-to-build-a-horizontal-jquery-accordion/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 14:29:21 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[accordion]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[slider]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=965</guid>
		<description><![CDATA[Sliders, accordions oh my! If you search for jQuery slider, you will find tons of posts and articles on how to do so. There are plenty of ways of building one, and I haven&#8217;t really seen any two that were exactly the same. Hell, even I wrote on how to build a jQuery slider, using [...]]]></description>
			<content:encoded><![CDATA[<h3>Sliders, accordions oh my!</h3>
<p>If you search for jQuery slider, you will find tons of posts and articles on how to do so. There are plenty of ways of building one, and I haven&#8217;t really seen any two that were exactly the same. Hell, even I wrote on <a href="http://jc-designs.net/blog/2010/03/jquery-slider-tutorial-for-beginners-how-i-did-mine/">how to build a jQuery slider</a>, using the slider on this blog as an example. You know what is quite difficult to find though? Tutorials on horizontal accordions. I had a hell of a time figuring out how, because most of the articles are about using a plugin. Which, if you have read any of my posts in the past, you will know that I like to do things myself most of the time. I only found one that was super helpful, and it was buried a few pages in. The only problem is that it was using an unordered list, and I needed it to use divs. Luckily for me it was easy to change, and if you care to view the original tutorial over at <a href="http://www.designchemical.com/blog/index.php/jquery/jquery-simple-horizontal-accordion/">Design Chemical</a> (written by a guy named Lee I believe), please do so and tell him he rocks. Take a look at the demo first so you can see what the end result looks like.</p>
<p><a class="viewDemo" href="http://www.jc-designs.net/demo/accordion.html" target="_blank">View Demo</a></p>
<p><span id="more-965"></span></p>
<h3>First things first &#8211; the HTML</h3>
<p>Let me first state that the there is an issue with IE7 with the HTML/CSS. The Javascript works fine, but the image is too far over. I will post the corrections for it later, I just wanted to get the post up for you since it has been a while since I have written anything.</p>
<p><strong>Note: I am only showing one panel below, but I am using 4. You can see the all of them if you view the source in the demo</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;div id=&quot;accordion&quot;&gt;
    &lt;div class=&quot;panel&quot;&gt;
      &lt;div class=&quot;pink&quot;&gt;&lt;/div&gt;
      &lt;div class=&quot;panelContent p1&quot;&gt; &lt;strong&gt;Section 1 Header&lt;/strong&gt;&lt;br/&gt;
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. In iaculis volutpat quam, non suscipit arcu accumsan at. Aliquam pellentesque.
      &lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p>As you can see, there is not much there. If you looked at the demo, you will see what is going on in the above HTML. A wrapper (&#8216;#accordion&#8217;), a div for each little pink section (.&#8217;pink&#8217;), a div for each individual panel (&#8216;.panel&#8217;), and the content within &#8211; pretty easy stuff.</p>
<h3>The styles</h3>
<p>Again, not much going on with the styles. Below is the important stuff, which doesn&#8217;t include the classes that call the individual pink bar images.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #cc00cc;">#accordion</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">list-style</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">none</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">margin</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">30px</span> <span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">padding</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">height</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">270px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">980px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">margin</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #cc66cc;color: #439AD0;">0</span> <span style="color: #cc66cc;color: #439AD0;">0</span> <span style="color: #cc66cc;color: #439AD0;">0</span> <span style="color: #933;">11px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">border-top</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;color: #439AD0;">solid</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">border-bottom</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;color: #439AD0;">solid</span> <span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">overflow</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">hidden</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#accordion</span> <span style="color: #6666ff;color: #439AD0;">.panel</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">float</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #000000; font-weight: bold;color: #439AD0;">left</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">display</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">block</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">height</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">270px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">44px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">overflow</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">hidden</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">color</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #cc00cc;">#666666</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">text-decoration</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">none</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">font-size</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">line-height</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">1.5em</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#accordion</span> <span style="color: #6666ff;color: #439AD0;">.panel</span><span style="color: #6666ff;color: #439AD0;">.active</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">848px</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #6666ff;color: #439AD0;">.panelContent</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">padding</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">15px</span> <span style="color: #933;">15px</span> <span style="color: #933;">15px</span> <span style="color: #933;">55px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">height</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">240px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">778px</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #6666ff;color: #439AD0;">.pink</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">42px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">height</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">270px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">float</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #000000; font-weight: bold;color: #439AD0;">left</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">background</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">url</span><span style="color: #00AA00;color: #439AD0;">&#40;</span><span style="color: #ff0000; font-style: italic;">../images/accordionSprite.png</span><span style="color: #00AA00;color: #439AD0;">&#41;</span> <span style="color: #993333;color: #439AD0;">no-repeat</span> <span style="color: #933;">4px</span> <span style="color: #933;">85px</span> <span style="color: #cc00cc;">#f980a1</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">border-right</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #933;">2px</span> <span style="color: #993333;color: #439AD0;">solid</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">cursor</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">pointer</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #6666ff;color: #439AD0;">.last</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">border</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">none</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span></pre></div></div>

<p>Some things to note about the CSS. My total width is 980px. The reason the active panel (the one showing) is 848px is because there are 4 panels, 3 of which are closed and each of them have a total width of 44px. So 980 &#8211; (44 x 3) = 848px. It is 44px because the width is 42px plus a two pixel border. See, there is some math you have to do to get everything to fit correctly. Make sure you are paying attention to that when you are building your own.</p>
<h3>jQuery please!</h3>
<p>Now on to what you really wanted to see, right? I&#8217;ll explain what is happening below.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span>document<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
&nbsp;
    activePanel <span style="color: #339933;color: #439AD0;">=</span> $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">&quot;#accordion div.panel:first&quot;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
    $<span style="color: #009900;color: #439AD0;">&#40;</span>activePanel<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'active'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
    $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">&quot;#accordion&quot;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delegate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.panel'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #3366CC;color: #439AD0;">'click'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span>e<span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
        <span style="color: #000066; font-weight: bold;color: #439AD0;">if</span><span style="color: #009900;color: #439AD0;">&#40;</span> <span style="color: #339933;color: #439AD0;">!</span> $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #000066; font-weight: bold;color: #439AD0;">is</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.active'</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span>activePanel<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>width<span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;44px&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #CC0000;color: #439AD0;">300</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>width<span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;848px&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #CC0000;color: #439AD0;">300</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#accordion .panel'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'active'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'active'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			activePanel <span style="color: #339933;color: #439AD0;">=</span> <span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #339933;color: #439AD0;">;</span>
		 <span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">;</span>
    <span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>Once again, not a heck of a lot of code to get this thing going. The first two lines, after the document ready thing of course, is for getting the first panel within the wrapper (&#8216;#accordion&#8217;), and giving it a class of &#8216;active&#8217;. All that class does is change the width from 44px to 848px. Whichever panel has the &#8216;active&#8217; class is the one that is showing.</p>
<p>Next comes the click function, which I am using delegate() for so that there is only one event handler, rather than one for each panel. Then the script checks to see if the panel click is NOT the active one, and if it isn&#8217;t, animate the active one&#8217;s width down to 44px, with the animation time set to 300. Then animate the panel that was clicked, so that it&#8217;s width becomes 848px, at the same speed.</p>
<p>After that, it removes the &#8216;active&#8217; class from all of the panels, and adds the class back to the one that was clicked. The last line then makes the &#8216;activePanel&#8217; variable be the panel that was clicked.</p>
<p>One last note. I did have the following in place of the 300 speed, but it didn&#8217;t seem to need it, so I took it out. It clears the animation queue, but I think the accordion moves so fast that it doesn&#8217;t seem to matter if it is in the script.</p>
<pre lang="javascript">
$(activePanel).animate({width: "44px"}, {duration:300, queue:false});<br />
$(this).animate({width: "848px"}, {duration:300, queue:false});
</pre</p>
<h3>Conclusion</h3>
<p>I am using this exact script in a freelance project I am working on (which I will show you guys when it's done), and I am pretty happy with it. Again, I have to change the HTML and CSS around because of IE7's issue, but the script itself works great in 7 or 8. Didn't check IE6 because I don't really care anymore unless someone specifically asks for it to be supported.</p>
<p>Let me know what you think, and leave a comment!</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=965" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/07/how-to-build-a-horizontal-jquery-accordion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Fly Out Menu Update, And Web Development Goodies</title>
		<link>http://jc-designs.net/blog/2011/05/jquery-fly-out-menu-update-and-web-development-goodies/</link>
		<comments>http://jc-designs.net/blog/2011/05/jquery-fly-out-menu-update-and-web-development-goodies/#comments</comments>
		<pubDate>Wed, 18 May 2011 18:56:52 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=921</guid>
		<description><![CDATA[JC Designs update I know it has been like a week and a half since I last posted, but my life has been busy. Very busy. Today started out crazy, with a person in the UK wanting 63 psd files sliced and built. Ya, you read that right&#8230;.63! I thought to myself &#8220;Self, this could [...]]]></description>
			<content:encoded><![CDATA[<h3>JC Designs update</h3>
<p>I know it has been like a week and a half since I last posted, but my life has been busy. Very busy. Today started out crazy, with a person in the UK wanting 63 psd files sliced and built. Ya, you read that right&#8230;.63! I thought to myself &#8220;Self, this could be some good money.&#8221; All had the same outer shell, but the content areas were insanely packed with forms, icons, lists, navs&#8230;seriously a ton of work. Was for a online gaming company. You know how she found me? Googled &#8220;how to slice a psd&#8221; and I showed up on the bottom of one of the pages, she came here, clicked contact&#8230;and there you go. The problem? Budget was $1200 and needed it in 2 weeks. I actually felt bad turning that down, but there is no way I was going to go through that stress, and that amount of work for $1200. I was think at the least 5-6k.</p>
<p>Anyway, here is the list of goodies I&#8217;ll comment on later:</p>
<ul>
<li>CSS3 -moz-crisp-edges, and -webkit-mask</li>
<li>CSS3 Gradient lines under links</li>
<li>CSS Regions</li>
</ul>
<p><span id="more-921"></span></p>
<h3>jQuery Fly Out Menu Update</h3>
<p>New story now, still with me? A couple of days ago I received an really cool email from a guy that searched for &#8220;jquery fly-out menu&#8221; and got to my post <a href="http://jc-designs.net/blog/2011/01/a-simple-jquery-fly-out-menu/" target="_blank">here</a>. He thanked me a lot for the menu, but was having problems with it in IE7 and 8 after doing some modifications to it. I had already tested it in those browsers and there were no problems. Unless of course you bring the width in so that the sub menus appear above the main menu. The problem is that in IE7/8, they appear below the other main nav li&#8217;s. I thought it would be a simple fix, but after 2 hours last night, I was getting really pissed. I solved it through random guessing and some head slapping.</p>
<p>That menu puts a position: relative on all the &#8216;li&#8217; within the menu. Works fine if you don&#8217;t screw with my code because of the way I animate it. The solution? Couldn&#8217;t have been easier. Remove the relative position off of the &#8216;li&#8217;s and create a class that adds it back on hover (using jquery), and removes it on roll off. You can see the updated code on <a href="http://jc-designs.net/blog/2011/01/a-simple-jquery-fly-out-menu/" target="_blank">A Simple jQuery Fly Out Menu</a> post. Soooo&#8230;&#8221;fixed&#8221; the menu, and I got to see someone use my menu on their site. Was very cool. He also noted that I was the only developer to actually help him, and that this was the 5th menu he&#8217;d tried. Also cool was the fact that his boss was excited to put me on paid retainer to help out when needed.</p>
<h3>Recent Web Development Goodies &#8211; FF and Webkit are going nuts!</h3>
<p>Let&#8217;s start off with CSS3 -moz-crisp-edges, and -webkit-mask. Smashing Magazine had a pretty good article about <a href="http://www.smashingmagazine.com/2011/05/11/the-future-of-css-experimental-css-properties/">The Future of CSS: Experimental CSS Properties</a>. It talked about some cool new stuff, and the first one I liked was -moz-crisp-edges. This is cool if you are doing responsive design, where the images scale as your window size shrinks/expands. It avoids blurry edges on the image as it is being manipulated by the browser. The CSS looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;color: #439AD0; font-weight: bold;">html  <span style="color: #00AA00;color: #439AD0;">&#123;</span> image-rendering<span style="color: #00AA00;color: #439AD0;">:</span> -moz-crisp-edges<span style="color: #00AA00;color: #439AD0;">;</span> <span style="color: #00AA00;color: #439AD0;">&#125;</span>        <span style="color: #808080; font-style: italic;color: #439AD0;">/* all images, videos, background-images */</span>
img   <span style="color: #00AA00;color: #439AD0;">&#123;</span> -ms-interpolation-mode<span style="color: #00AA00;color: #439AD0;">:</span> nearest-neighbor<span style="color: #00AA00;color: #439AD0;">;</span> <span style="color: #00AA00;color: #439AD0;">&#125;</span> <span style="color: #808080; font-style: italic;color: #439AD0;">/* all images, IE */</span></pre></div></div>

<p>You can read more about it and a few other properties on <a href="https://developer.mozilla.org/en/CSS/image-rendering">Mozilla&#8217;s image rendering documents</a>.</p>
<p>The second one I liked was -webkit-mask. Basically it allows you to mask an image using an element with a CSS3 gradient applied to it, or a semi-transparent png. Very cool, and I can see myself using something like that with the gradient, but if I was going to go through the trouble of making a png to mask it, I might as well just create the entire thing in Photoshop. Here is what the CSS would look like:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #6666ff;color: #439AD0;">.element2</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">background</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">url</span><span style="color: #00AA00;color: #439AD0;">&#40;</span><span style="color: #ff0000; font-style: italic;">img/image.jpg</span><span style="color: #00AA00;color: #439AD0;">&#41;</span> <span style="color: #993333;color: #439AD0;">repeat</span><span style="color: #00AA00;color: #439AD0;">;</span>
	-webkit-mask<span style="color: #00AA00;color: #439AD0;">:</span> -webkit-gradient<span style="color: #00AA00;color: #439AD0;">&#40;</span>linear<span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #000000; font-weight: bold;color: #439AD0;">left</span> <span style="color: #000000; font-weight: bold;color: #439AD0;">top</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #000000; font-weight: bold;color: #439AD0;">left</span> <span style="color: #000000; font-weight: bold;color: #439AD0;">bottom</span><span style="color: #00AA00;color: #439AD0;">,</span> from<span style="color: #00AA00;color: #439AD0;">&#40;</span>rgba<span style="color: #00AA00;color: #439AD0;">&#40;</span><span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">,</span><span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">,</span><span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">,</span><span style="color: #cc66cc;color: #439AD0;">1</span><span style="color: #00AA00;color: #439AD0;">&#41;</span><span style="color: #00AA00;color: #439AD0;">&#41;</span><span style="color: #00AA00;color: #439AD0;">,</span> to<span style="color: #00AA00;color: #439AD0;">&#40;</span>rgba<span style="color: #00AA00;color: #439AD0;">&#40;</span><span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">,</span><span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">,</span><span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">,</span><span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">&#41;</span><span style="color: #00AA00;color: #439AD0;">&#41;</span><span style="color: #00AA00;color: #439AD0;">&#41;</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span></pre></div></div>

<h3>CSS3 Gradient lines under links</h3>
<p>I don&#8217;t know about you guys, but I build a LOT of different kinds of navigations. A very common thing I see come across my desk is to use a line between the links, or under them to show they are being hovered over. I&#8217;ve been using images to get the effect going, but this cool cat wrote some nice styles to do it with just CSS. He&#8217;s got a version that does not use pseudo-elements too! <a href="http://playground.genelocklin.com/gradient-hr/#links">Read it</a> and thank me for passing this on to you. Oh, and scroll down on his page and check out the link about adding depth to a website. Easy, simple, and I can&#8217;t believe I haven&#8217;t seen more of that.</p>
<h3>CSS Regions &#8211; Ask and ye shall receive!</h3>
<p>A while back I wrote about wishing you could <a href="http://jc-designs.net/blog/2010/08/css-wish-list-plotting-div-points/" target="_blank">create shapes using CSS</a>. Weird ass shapes, like polygons, circles or whatever. Well gues what? Adobe, of all people obviously reads my blog, and because they respect me sooooo much, decided that was a GREAT idea. It&#8217;s called <a href="http://theleggett.com/2011/05/10/css-regions-coming-soon/">CSS Regions</a>. There are a TON of different properties invovled, but here is a list from their site about it:</p>
<ul>
<li>Story threading — allows content to flow in multiple disjointed boxes expressed in CSS and HTML, making it possible to express more complex, magazine-style threaded layouts, including pull quotes and sidebars.</li>
<li>Region styling — allows content to be styled based on the region it flows into. For example, the first few lines that fit into the first region of an article may be displayed with a different color or font, or headers flowing in a particular region may have a different background color or size. Region styling is not currently implemented in the CSS Regions prototype.</li>
<li>Arbitrary content shapes and exclusions — allows content to fit into arbitrary shapes (not just rectangular boxes) or to flow around complex shapes.</li>
</ul>
<p>You can download demos of it <a href="http://labs.adobe.com/downloads/cssregions.html">here</a> and see some samples. The below CSS example is from a section of a pie chart, so this one line will make one piece of pie:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #6666ff;color: #439AD0;">.slice4</span> <span style="color: #6666ff;color: #439AD0;">.region</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
-webkit-wrap-shape<span style="color: #00AA00;color: #439AD0;">:</span> polygon<span style="color: #00AA00;color: #439AD0;">&#40;</span><span style="color: #933;">217px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">225px</span> <span style="color: #933;">217px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">225px</span> <span style="color: #933;">217px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">0px</span> <span style="color: #933;">179px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">3px</span> <span style="color: #933;">143px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">12px</span> <span style="color: #933;">110px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">26px</span> <span style="color: #933;">80px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">46px</span> <span style="color: #933;">53px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">70px</span> <span style="color: #933;">31px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">98px</span> <span style="color: #933;">13px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">131px</span> <span style="color: #933;">0px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">167px</span> <span style="color: #933;">217px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">225px</span> <span style="color: #933;">217px</span><span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #933;">225px</span> <span style="color: #00AA00;color: #439AD0;">&#41;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span></pre></div></div>

<p>Ok, I know I wished for it, but I really don&#8217;t want to plot all that out. This is one of those &#8220;cool&#8221; things, but totally impractical. Can&#8217;t see myself ever doing that even if it was supported by all modern browsers. Who knows though. Never say never.</p>
<h3>They are good discussion pieces, but would you use them?</h3>
<p>Honestly, these are all pretty neat. I would use the gradient lines and the -moz-crisp-edges, but the the shapes in CSS Regions&#8230;not so much. The documents talk about other things that might be useful, but I dislike things that only work in one browser.</p>
<p>What do you guys think?</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=921" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/05/jquery-fly-out-menu-update-and-web-development-goodies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial On Using setInterval To Make A jQuery Rotator</title>
		<link>http://jc-designs.net/blog/2011/04/tutorial-on-using-setinterval-to-make-a-jquery-rotator/</link>
		<comments>http://jc-designs.net/blog/2011/04/tutorial-on-using-setinterval-to-make-a-jquery-rotator/#comments</comments>
		<pubDate>Thu, 21 Apr 2011 14:43:14 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=888</guid>
		<description><![CDATA[A combination of things I was tasked last week with building&#8230;well, I don&#8217;t know what the hell to call it, but at work we named it &#8220;the wheel.&#8221; Basically, it is a circle with a bunch of gray icons around it. I needed to get them to change to blue, show a larger graphic with [...]]]></description>
			<content:encoded><![CDATA[<h3>A combination of things</h3>
<p>I was tasked last week with building&#8230;well, I don&#8217;t know what the hell to call it, but at work we named it &#8220;the wheel.&#8221; Basically, it is a circle with a bunch of gray icons around it. I needed to get them to change to blue, show a larger graphic with additional content, and change to the next icon after a certain amount of time. When one of the icons is clicked though, the animation has to stop, and show whatever content goes with that icon. I used setInterval to accomplish the rotation through the icons, and pretty much the same jQuery I used on the <a href="http://jc-designs.net/blog/2011/04/jquery-portfolio-content-gallery/">Portfolio Content Gallery</a> I wrote about. You&#8217;ll get a better idea of what I am talking about if you see it. I sped up the rotation so you don&#8217;t have to wait as long.</p>
<p><a class="viewDemo" href="http://www.jc-designs.net/demo/wheel/wheel.html" target="_blank">View Demo</a></p>
<p>I&#8217;m still learning Javascript/jQuery, and I have never used setInterval before, so this was a lesson for me as well. Turns out it is actually pretty easy, but I thought I would show you how to accomplish this so you don&#8217;t have to do any ridiculous searches like I did.</p>
<p><span id="more-888"></span></p>
<h3>The HTML you need</h3>
<p>There is not a lot to this, but seeing the structure will help. The only difference between this and the actual HTML I used is that there are eight content divs, where I am only showing one below. You can view all of the HTML in the demo.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;div id=&quot;wheelContainer&quot;&gt;
	&lt;div id=&quot;wheel&quot;&gt;
		&lt;div id=&quot;wheelOne&quot; class=&quot;wheelIcon&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/div&gt;
		&lt;div id=&quot;wheelTwo&quot; class=&quot;wheelIcon&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/div&gt;
		&lt;div id=&quot;wheelThree&quot; class=&quot;wheelIcon&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/div&gt;
		&lt;div id=&quot;wheelFour&quot; class=&quot;wheelIcon&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/div&gt;
		&lt;div id=&quot;wheelFive&quot; class=&quot;wheelIcon&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/div&gt;
		&lt;div id=&quot;wheelSix&quot; class=&quot;wheelIcon&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/div&gt;
		&lt;div id=&quot;wheelSeven&quot; class=&quot;wheelIcon&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/div&gt;
		&lt;div id=&quot;wheelEight&quot; class=&quot;wheelIcon&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/div&gt;
	&lt;/div&gt;
        &lt;div id=&quot;wheelContentContainer&quot;&gt;
		&lt;div id=&quot;wheelOneContent&quot; class=&quot;wheelContent&quot;&gt;
			&lt;div class=&quot;wheelLargeImage&quot; id=&quot;wheelImage1&quot;&gt;&lt;/div&gt;
			&lt;div class=&quot;wheelText&quot;&gt;
				&lt;p class=&quot;wheelHeading&quot;&gt;Websites&lt;/p&gt;
				&lt;p&gt;Content 1 goes here&lt;/p&gt;
			&lt;/div&gt;
		&lt;/div&gt;
         &lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<h3>The jQuery using setInterval</h3>
<p>I&#8217;ll show you all of the jQuery I used, and then go through it line by line to explain what is going on.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span>document<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
	<span style="color: #003366; font-weight: bold;color: #439AD0;">var</span> wheels <span style="color: #339933;color: #439AD0;">=</span> $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.wheelIcon'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
        <span style="color: #003366; font-weight: bold;color: #439AD0;">var</span> content <span style="color: #339933;color: #439AD0;">=</span> $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.wheelContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
	$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#wheel'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delegate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'div'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #3366CC;color: #439AD0;">'click'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
		stopRotation<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		<span style="color: #006600; font-style: italic;color: #439AD0;">//change the background-position on x-axis so that they become blue icons</span>
		wheels.<span style="color: #660066;">removeClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageChange'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageChange'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
&nbsp;
		<span style="color: #006600; font-style: italic;color: #439AD0;">//Show or hide the content divs based on which icon is clicked</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.wheelContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">500</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.wheelContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;color: #439AD0;">&#40;</span>$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>	
	<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> rotation<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		rotateIcon <span style="color: #339933;color: #439AD0;">=</span> setInterval<span style="color: #009900;color: #439AD0;">&#40;</span>nextIcon<span style="color: #339933;color: #439AD0;">,</span> <span style="color: #CC0000;color: #439AD0;">4000</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	<span style="color: #009900;color: #439AD0;">&#125;</span>
&nbsp;
	i <span style="color: #339933;color: #439AD0;">=</span> <span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> nextIcon<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		wheels.<span style="color: #660066;">removeClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageChange'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span>wheels<span style="color: #009900;color: #439AD0;">&#91;</span>i<span style="color: #009900;color: #439AD0;">&#93;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageChange'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span>content<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">1000</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span>content<span style="color: #009900;color: #439AD0;">&#91;</span>i<span style="color: #009900;color: #439AD0;">&#93;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>	
		<span style="color: #000066; font-weight: bold;color: #439AD0;">if</span> <span style="color: #009900;color: #439AD0;">&#40;</span>i<span style="color: #339933;color: #439AD0;">&lt;</span><span style="color: #CC0000;color: #439AD0;">7</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
			i<span style="color: #339933;color: #439AD0;">++;</span>	
		<span style="color: #009900;color: #439AD0;">&#125;</span> <span style="color: #000066; font-weight: bold;color: #439AD0;">else</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
			i <span style="color: #339933;color: #439AD0;">=</span> <span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">;</span>
		<span style="color: #009900;color: #439AD0;">&#125;</span>
	<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> stopRotation<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		clearInterval<span style="color: #009900;color: #439AD0;">&#40;</span>rotateIcon<span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	<span style="color: #009900;color: #439AD0;">&#125;</span>
&nbsp;
	nextIcon<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	rotation<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>Well, starting with the first line of the actual script, I&#8217;m declaring a variable for all the divs with the class &#8216;wheelIcon&#8217;. That way I am not typing so much later. Same thing with all the content divs. The next block deals with adding/removing a class, so that the icon changes from gray to blue when clicked. It is doing more than that of course.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#wheel'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delegate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'div'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #3366CC;color: #439AD0;">'click'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
		stopRotation<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		<span style="color: #006600; font-style: italic;color: #439AD0;">//change the background-position on x-axis so that they become blue icons</span>
		wheels.<span style="color: #660066;">removeClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageChange'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageChange'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
&nbsp;
		<span style="color: #006600; font-style: italic;color: #439AD0;">//Show or hide the content divs based on which icon is clicked</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.wheelContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">500</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.wheelContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;color: #439AD0;">&#40;</span>$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>	
	<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>I&#8217;m using delegate() so that there isn&#8217;t a ton of event handler&#8217;s flying around. It places the handler on the div with the id of &#8216;wheel&#8217;, and if any of the divs within it are clicked, it runs the function. One handler rather than eight. The next line is calling the function &#8216;stopRotation&#8217; which clears the interval, but I&#8217;ll get to that.</p>
<p>So an icon is clicked, stops the rotation, and we get to the next couple of lines. It removes the class &#8216;imageChange&#8217; from ALL of the icon divs, and adds it back on to the one that was clicked. The last piece in this section does kind of the same thing, but with the content divs. It fades out ALL the content divs, and fades in the one whose index value is equal to the index value of the icon that was clicked. Now on to the fun!</p>
<h3>The home stretch &#8211; setInterval</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> rotation<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		rotateIcon <span style="color: #339933;color: #439AD0;">=</span> setInterval<span style="color: #009900;color: #439AD0;">&#40;</span>nextIcon<span style="color: #339933;color: #439AD0;">,</span> <span style="color: #CC0000;color: #439AD0;">4000</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	<span style="color: #009900;color: #439AD0;">&#125;</span>
&nbsp;
	i <span style="color: #339933;color: #439AD0;">=</span> <span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> nextIcon<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		wheels.<span style="color: #660066;">removeClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageChange'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span>wheels<span style="color: #009900;color: #439AD0;">&#91;</span>i<span style="color: #009900;color: #439AD0;">&#93;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageChange'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span>content<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">1000</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span>content<span style="color: #009900;color: #439AD0;">&#91;</span>i<span style="color: #009900;color: #439AD0;">&#93;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>	
		<span style="color: #000066; font-weight: bold;color: #439AD0;">if</span> <span style="color: #009900;color: #439AD0;">&#40;</span>i<span style="color: #339933;color: #439AD0;">&lt;</span><span style="color: #CC0000;color: #439AD0;">7</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
			i<span style="color: #339933;color: #439AD0;">++;</span>	
		<span style="color: #009900;color: #439AD0;">&#125;</span> <span style="color: #000066; font-weight: bold;color: #439AD0;">else</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
			i <span style="color: #339933;color: #439AD0;">=</span> <span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">;</span>
		<span style="color: #009900;color: #439AD0;">&#125;</span>
	<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> stopRotation<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		clearInterval<span style="color: #009900;color: #439AD0;">&#40;</span>rotateIcon<span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	<span style="color: #009900;color: #439AD0;">&#125;</span>
&nbsp;
	nextIcon<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	rotation<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>I created three functions here. One to start the timed rotation, one to do what it should during the interval, and one to stop the rotation. The first starts it, and it is pretty simple. I gave it a name of &#8216;rotation&#8217;, and set a variable to setInterval with the parameters of another function, and a time period of 4 seconds. I set a variable of &#8216;i&#8217; to &#8217;0&#8242;, which I will use in the function I am passing into the setInterval.</p>
<p>The function &#8216;nextIcon&#8217; does a lot of what the click event does. I remove the class &#8216;imageChange&#8217; from every icon, the add it to the icon with an index value of &#8216;i&#8217;, which is zero the first time around. That means the first icon is blue right off the bat. I then fade out all the content divs, and fade in the one that has an index also equal to &#8216;i&#8217;, which at the start is again, zero.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #000066; font-weight: bold;color: #439AD0;">if</span> <span style="color: #009900;color: #439AD0;">&#40;</span>i<span style="color: #339933;color: #439AD0;">&lt;</span><span style="color: #CC0000;color: #439AD0;">7</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
i<span style="color: #339933;color: #439AD0;">++;</span>	
<span style="color: #009900;color: #439AD0;">&#125;</span> <span style="color: #000066; font-weight: bold;color: #439AD0;">else</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
i <span style="color: #339933;color: #439AD0;">=</span> <span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span></pre></div></div>

<p>The above says if i is less than zero, add 1 to it, otherwise set &#8216;i&#8217; back to zero. That keeps the rotation going after it gets finished. Just to note, I have eight content divs, but we are going by index value, which starts at 0, rather than 1.</p>
<p>The last section is the function that stops the rotation. All it does is clear the interval that is set in the rotation function.</p>
<p>Finally, I call the &#8216;nextIcon&#8217; function to get it going, and then the &#8216;rotation&#8217; function to set the interval.</p>
<h3>Final thoughts on setInterval</h3>
<p>I had always wanted to know how to do what I did with this little project, and it was cool to learn how to do it. I was surprised at how uncomplicated it actually is. The only hard part was doing a bit of &#8216;googling&#8217; to figure some things out. Hopefully this little tutorial saves you some time and taught you something.</p>
<p><strong>If you have used setInterval before, show us what you did!</strong></p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=888" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/04/tutorial-on-using-setinterval-to-make-a-jquery-rotator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery Portfolio Content Gallery</title>
		<link>http://jc-designs.net/blog/2011/04/jquery-portfolio-content-gallery/</link>
		<comments>http://jc-designs.net/blog/2011/04/jquery-portfolio-content-gallery/#comments</comments>
		<pubDate>Fri, 01 Apr 2011 22:08:21 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=852</guid>
		<description><![CDATA[Been very busy First, apologies to my subscribers for not writing a lot recently, but I have been working some overtime, and redesigning my website&#8217;s interior pages. But I was working on my portfolio page and thought I would share what I have done. All in all, it is not overly complicated, but I like [...]]]></description>
			<content:encoded><![CDATA[<h3>Been very busy</h3>
<p><img src="http://jc-designs.net/newimages/blogImages/portScreen.jpg" alt="Portfolio image" class="right"/>First, apologies to my subscribers for not writing a lot recently, but I have been working some overtime, and redesigning my website&#8217;s interior pages. But I was working on my portfolio page and thought I would share what I have done. All in all, it is not overly complicated, but I like that it is clean and simple. You&#8217;ll also get to see the beginnings of my redesign of my interior pages (just keep in mind that it is not finished yet). Take a look at my new portfolio page so far:</p>
<p><a class="viewDemo" href="http://jc-designs.net/portfolio" target="_blank">View Demo</a><br />
<span id="more-852"></span></p>
<h3>The nuts and bolts</h3>
<p>I wanted my portfolio page to be simple, and I think I achieved that. Content for the first port image is already loaded, and when you click on an image, the arrow slides and the content switches to match the image. Here is the HTML I used:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;div id=&quot;portContainer&quot;&gt;
     &lt;div id=&quot;portArrow&quot;&gt;&lt;/div&gt;
     &lt;ul&gt;
          &lt;li id=&quot;portOne&quot; class=&quot;slide&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
          &lt;li id=&quot;portTwo&quot; class=&quot;slide&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
          &lt;li id=&quot;portThree&quot; class=&quot;slide&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
          &lt;li id=&quot;portFour&quot; class=&quot;slide&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
          &lt;li id=&quot;portFive&quot; class=&quot;slide&quot;&gt;&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;&lt;/li&gt;
     &lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&quot;portContentContainer&quot;&gt;
     &lt;div id=&quot;portOneContent&quot; class=&quot;portContent&quot;&gt;
          Test Content 1
     &lt;/div&gt;
 &lt;div id=&quot;portTwoContent&quot; class=&quot;portContent&quot;&gt;
          Test Content 2
     &lt;/div&gt;
 &lt;div id=&quot;portThreeContent&quot; class=&quot;portContent&quot;&gt;
          Test Content 3
     &lt;/div&gt;
 &lt;div id=&quot;portFourContent&quot; class=&quot;portContent&quot;&gt;
          Test Content 4
     &lt;/div&gt;
 &lt;div id=&quot;portFiveContent&quot; class=&quot;portContent&quot;&gt;
          Test Content 5
     &lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p>The CSS doesn&#8217;t really matter for this, other than the margin for the arrow is set to 0, because that is what I change using a jQuery animation. Let&#8217;s take a look at that, and then I&#8217;ll explain what I did to achieve it.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #003366; font-weight: bold;color: #439AD0;">var</span> slides <span style="color: #339933;color: #439AD0;">=</span> $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.slide'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #003366; font-weight: bold;color: #439AD0;">var</span> contentWidth <span style="color: #339933;color: #439AD0;">=</span> $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.slide'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #003366; font-weight: bold;color: #439AD0;">var</span> currentPosition <span style="color: #339933;color: #439AD0;">=</span> <span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
slides.<span style="color: #660066;">click</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> <span style="color: #009900;color: #439AD0;">&#40;</span>e<span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
	currentPosition <span style="color: #339933;color: #439AD0;">=</span> $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;color: #439AD0;">//Move the arrow thing move to the right, the 42 is the margin between the slide divs</span>
	$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#portArrow'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
		<span style="color: #3366CC;color: #439AD0;">'marginLeft'</span> <span style="color: #339933;color: #439AD0;">:</span>  <span style="color: #009900;color: #439AD0;">&#40;</span>contentWidth <span style="color: #339933;color: #439AD0;">+</span> <span style="color: #CC0000;color: #439AD0;">42</span> <span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #339933;color: #439AD0;">*</span> <span style="color: #009900;color: #439AD0;">&#40;</span>currentPosition<span style="color: #009900;color: #439AD0;">&#41;</span>
		<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #CC0000;color: #439AD0;">200</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;color: #439AD0;">//Show or hide the 4 items below based on which slide is clicked</span>
	$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.portContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">500</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.portContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;color: #439AD0;">&#40;</span>$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>	
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<h3>What is jQuery doing there?</h3>
<p>See? Very few lines of jQuery were needed to get this to work. The first line is just a variable to reference all the list-items with the class &#8220;slide&#8221;. Which technically you could ditch, because I only call it once. I left it in there because at the time, I didn&#8217;t really know what I was going to be doing. The second line is another variable used for the width of each individual
<li>. The final variable is to track the position of of the arrow, which is set to &#8217;0&#8242;.</p>
<p>Then we come to the click event attached to the li&#8217;s. The currentPosition variable&#8217;s value changes to be the index number of whatever
<li> is clicked. If you click on the second image it equals 1, if you click on the third image, it equals 2, and so on and so forth. Once an li is clicked, the animation kicks in.</p>
<p>The arrow (which is a div with an id of &#8216;portArrow&#8217;) is moved (left or right) a total of the li&#8217;s width, plus 42, which is the margin between each
<li>, and then multiplied by the current position. That number becomes the arrow&#8217;s left margin. If you click on the first image, you get (168 + 42) * 0, which is 0, so the arrow&#8217;s left margin is set to 0, and the arrow moves to the left. Unless of course the arrow was already on the first image.</p>
<p>The last part deals with the content underneath. This line just fades out whatever content is showing, and gives a delay of 1/2 a second, before going to the next part:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.portContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeOut</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">500</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>The last line:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.portContent'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">eq</span><span style="color: #009900;color: #439AD0;">&#40;</span>$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">index</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>This says, out of the div&#8217;s with a class of &#8216;portContent&#8217;, fade in the one that&#8217;s index matches the index of the
<li> that was clicked. Got it? Good.</p>
<h3>Extra credit question</h3>
<p>Now for a question for any experienced jQuery users. You will see that the little cog next to my logo is rotating. All that is, is an image sprite with 3 images, being shifted over. Unfortunately, I had to use a plugin for that. The plugin (<a href="http://www.spritely.net/">Spritely</a>) is cool, but I wanted to avoid it if possible, and do it myself. I came close by chaining multiple animations with very fast speeds, but I didn&#8217;t want it to go as fast as it was. I then tried chaining three .css() methods with delays in between inside a loop, but that didn&#8217;t work. Kind of looked like this (off the top of my head&#8230;not exact):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #000066; font-weight: bold;color: #439AD0;">for</span> <span style="color: #009900;color: #439AD0;">&#40;</span>i<span style="color: #339933;color: #439AD0;">=</span><span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">;</span>i<span style="color: #339933;color: #439AD0;">&lt;</span><span style="color: #CC0000;color: #439AD0;">50000</span><span style="color: #339933;color: #439AD0;">;</span>i<span style="color: #339933;color: #439AD0;">++</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#intCog'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'backgroundPosition'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #3366CC;color: #439AD0;">'-60px 0'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">100</span><span style="color: #009900;color: #439AD0;">&#41;</span>
     .<span style="color: #660066;">css</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'backgroundPosition'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #3366CC;color: #439AD0;">'-120px 0'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">100</span><span style="color: #009900;color: #439AD0;">&#41;</span>
     .<span style="color: #660066;">css</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'backgroundPosition'</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #3366CC;color: #439AD0;">'0 0'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">delay</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">100</span><span style="color: #009900;color: #439AD0;">&#41;</span>
&nbsp;
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>Obviously, this didn&#8217;t work, and I knew why right after I wrote it. It&#8217;s going to set to 0 0, but my thought was that it would step through it rather than slide through it like an animation would.</p>
<p><strong>The question:</strong> How do you change a value, like above, without the sliding like the animation has? I needed it to change to the value, not slide to the new position. I could have made 3 copies and faded them in and out, but that seemed ridiculous. All I can think of is maybe 3 chained animations and some hide/show methods like:</p>
<p>.hide().animation(background position change).show().hide().animation(background position change).show().hide() and so forth&#8230;really fast.</p>
<p>Help me out!</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=852" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/04/jquery-portfolio-content-gallery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A Simple jQuery Fly-Out Menu</title>
		<link>http://jc-designs.net/blog/2011/01/a-simple-jquery-fly-out-menu/</link>
		<comments>http://jc-designs.net/blog/2011/01/a-simple-jquery-fly-out-menu/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 23:25:25 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=703</guid>
		<description><![CDATA[I haven&#8217;t made a post about jQuery in a while Which is what made me decide to write my first post of 2011 on it. First, thank you to the people who commented here on The Web Machine in 2010. Also thanks to the over 730 RSS subscribers I have and the 25 or so [...]]]></description>
			<content:encoded><![CDATA[<h3>I haven&#8217;t made a post about jQuery in a while</h3>
<p>Which is what made me decide to write my first post of 2011 on it. First, thank you to the people who commented here on The Web Machine in 2010. Also thanks to the over 730 RSS subscribers I have and the 25 or so followers on Twitter. This blog has been up for about a year now, and I look forward to this one. I hate all of you comment spammers though! So huge thanks to Akismet.</p>
<p>Anyway&#8230;a while ago I had thought about creating WordPress themes and try my hand at selling them, but it soon became apparent that the market was saturated. I don&#8217;t feel like wasting my time right now on putting effort into that. On one of those themes though, while I am not happy with the look, I created a fly-out menu using jQuery that I really liked. I thought I would share that with you since it takes less than 8 lines of code. So take a look at the demo, and then we&#8217;ll jump right in.</p>
<p><strong>UPDATE 5/17/11: Removed the position:relative from the li style. It now gets the position:relative in the hover function in jQuery by adding/removing a class &#8216;addPosition&#8217;. This fixes the submenu appearing underneath the main menu in IE7/8. This was only noticable if you started changing the position of the submenu to be overlapping the main menu. My code here assumes you don&#8217;t do that, but with the fix it works great in IE7/8.</strong></p>
<p><strong>NOTE: In IE6, only the first level of the fly-out works. The second is cut off, but since most of us our on our way to not supporting it, I didn&#8217;t care. If you have the simple solution to fix that, let me know.</strong></p>
<p>Original:<br />
<a href="http://jc-designs.net/demo/flyout.html" target="_blank" class="viewDemo">View Demo</a></p>
<p>More stripped down version (asked for in comments and the CSS now shown in sample code below):<br />
<a href="http://jc-designs.net/demo/flyout2.html" target="_blank" class="viewDemo">View Demo</a></p>
<p><span id="more-703"></span><br />
Now that you have seen what it is supposed to do, let&#8217;s jump in. The HTML first:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">  &lt;div id=&quot;nav&quot;&gt;
    &lt;ul id=&quot;navList&quot;&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Home&lt;/a&gt;
        &lt;!-- This is the sub nav --&gt;
        &lt;ul class=&quot;listTab&quot;&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About This Template Here&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Flash&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;jQuery&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Blog&lt;/a&gt;
        &lt;!-- This is the sub nav --&gt;
        &lt;ul class=&quot;listTab&quot;&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About This Template Here&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Flash&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;jQuery&lt;/a&gt;
            &lt;ul class=&quot;listTab&quot;&gt;
              &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About This Template Here&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Flash&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href=&quot;#&quot;&gt;jQuery&lt;/a&gt;&lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About&lt;/a&gt;
        &lt;!-- This is the sub nav --&gt;
        &lt;ul class=&quot;listTab&quot;&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;About This Template Here&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Flash&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;jQuery&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Porfolio&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#&quot;&gt;Contact&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/div&gt;</pre></div></div>

<p>Fairly easy stuff there. It is a simple list with a byline under each item, and the first few list items have the fly out. Here is the CSS involved:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;color: #439AD0; font-weight: bold;">ul <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">margin</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">padding</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#nav</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">330px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">float</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #000000; font-weight: bold;color: #439AD0;">left</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">margin</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">50px</span> <span style="color: #cc66cc;color: #439AD0;">0</span> <span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#navList</span> li <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">list-style</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">none</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">margin</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc66cc;color: #439AD0;">0</span> <span style="color: #cc66cc;color: #439AD0;">0</span> <span style="color: #933;">10px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">float</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #000000; font-weight: bold;color: #439AD0;">left</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
&nbsp;
<span style="color: #6666ff;color: #439AD0;">.addPosition</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
<span style="color: #000000; font-weight: bold;color: #439AD0;">position</span><span style="color: #00AA00;color: #439AD0;">:</span><span style="color: #993333;color: #439AD0;">relative</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#navList</span> a <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">text-decoration</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">none</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">color</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">background-color</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">padding</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">display</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">block</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#navList</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">background-color</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc00cc;">#06F</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#navList</span> ul<span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #cc00cc;">#navList</span> ul ul <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">display</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">none</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">position</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">absolute</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">top</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">left</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">280px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">background-color</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #6666ff;color: #439AD0;">.listTab</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">z-index</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc66cc;color: #439AD0;">100</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#navList</span> <span style="color: #6666ff;color: #439AD0;">.listTab</span> li <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">margin</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc66cc;color: #439AD0;">0</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#navList</span> <span style="color: #6666ff;color: #439AD0;">.listTab</span> a<span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #cc00cc;">#navList</span> <span style="color: #6666ff;color: #439AD0;">.listTab</span> a<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">250px</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#navList</span> <span style="color: #6666ff;color: #439AD0;">.listTab</span> a <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">padding</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #933;">5px</span> <span style="color: #933;">10px</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#navList</span> li<span style="color: #3333ff;">:hover </span>ul ul<span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #cc00cc;">#navList</span> li<span style="color: #3333ff;">:hover </span>ul ul ul<span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #cc00cc;">#navList</span> li<span style="color: #3333ff;">:hover </span>ul ul ul ul <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">display</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">none</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #cc00cc;">#navList</span> li<span style="color: #3333ff;">:hover </span>ul<span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #cc00cc;">#navList</span> li li<span style="color: #3333ff;">:hover </span>ul<span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #cc00cc;">#navList</span> li li li<span style="color: #3333ff;">:hover </span>ul<span style="color: #00AA00;color: #439AD0;">,</span> <span style="color: #cc00cc;">#navList</span> li li li li<span style="color: #3333ff;">:hover </span>ul <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">display</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">block</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span></pre></div></div>

<p>The really important stuff in the CSS is where position relative is being used (the li&#8217;s), because the fly-out &#8216;ul&#8217; is positioned absolutely to them. Other than that, the display none and block on the &#8216;uls&#8217;. Everything else is just CSS to make the menu look pretty.</p>
<p>Here is the jQuery:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span>document<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span>$<span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		<span style="color: #006600; font-style: italic;color: #439AD0;">//Menu animation						</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#navList ul'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>display<span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;none&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span> <span style="color: #006600; font-style: italic;color: #439AD0;">//Fix Opera</span>
&nbsp;
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#navList li'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>  
                $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'addPosition'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'a'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #000066;color: #439AD0;">stop</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span><span style="color: #3366CC;color: #439AD0;">'width'</span> <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;280&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
   		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'ul:first'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>visibility <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;visible&quot;</span><span style="color: #339933;color: #439AD0;">,</span> display <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;none&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">400</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
  		<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
    		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'ul:first'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>visibility <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;hidden&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">400</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
   		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'a'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #000066;color: #439AD0;">stop</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span><span style="color: #3366CC;color: #439AD0;">'width'</span> <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;250&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
                $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'addPosition'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>Ok, I will admit that the first line I got from someone else. I have no idea what the hell that fixes, as I am unfamiliar with Opera (along with 3 billion other developers). It seems odd to me because my first CSS puts it at display: none anyways, but I&#8217;ve seen this before so I left it in.</p>
<p>NOTE: Found out Opera doesn&#8217;t hide the menus fast enough, that is why that is there.</p>
<p>The second line is where it all starts. The fly-out is just a hover function in jQuery. Simple yet effective. That is what I live for. I babble&#8230;the li(s) of the main &#8216;ul&#8217; get the hover function. The third line says &#8220;Find the link of the &#8216;li&#8217; you hovered on, stop any animation if there is any, and animate it so that the width grows to 250 pixels.&#8221;</p>
<p>The next line says find the first ul of the rolled over li, make it visible and set the display to none, then show it (which sets the display to block) over 4 miliseconds. I know it seems nuts to have the visibility to visible and yet display it to none, but with out the visible part, the fly-out would only show the first time then never appear again. It will work without the display set to none, but it looks like the show() works better when it is written in. I believe this has to do with show() changing the display, not the visibility.</p>
<p>The off hover section, does the exact opposite. The visibility is set to hidden, and the hide, which takes place again over 4 miliseconds, sets the display back to none. The final line stops any animation on the link, and then shrinks the width back to 250 pixels.</p>
<h3>And there you have it!</h3>
<p>A few lines of jQuery and you have a fly out menu. Most of the CSS is for styling. I have used some CSS3 here that won&#8217;t work in IE obviously, but the actual menu functions except for IE6 (see note above).</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=703" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2011/01/a-simple-jquery-fly-out-menu/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Wijmo And Headjs Reviews</title>
		<link>http://jc-designs.net/blog/2010/12/wijmo-and-headjs-reviews/</link>
		<comments>http://jc-designs.net/blog/2010/12/wijmo-and-headjs-reviews/#comments</comments>
		<pubDate>Mon, 13 Dec 2010 21:44:42 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Product Reviews]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=669</guid>
		<description><![CDATA[Undiscovered frontier I love seeing new things being created to make web developers&#8217; lives easier. Some suck, and some rock. Of course I am not the final judge. Usually I find these either from receiving a tweet or a list that shows all the stuff we, in theory, should be aware of. Two that I [...]]]></description>
			<content:encoded><![CDATA[<h3>Undiscovered frontier</h3>
<p>I love seeing new things being created to make web developers&#8217; lives easier. Some suck, and some rock. Of course I am not the final judge. Usually I find these either from receiving a tweet or a list that shows all the stuff we, in theory, should be aware of. Two that I was intrigued by recently are <a href="http://wijmo.com/">Wijmo</a>, a jQuery UI Widgets kit, and <a href="http://headjs.com/">Head JS</a>, which claims that it will be the only script you need in your head tag. Let&#8217;s get started, shall we?</p>
<h3>Apparently Wijmo is from outer space</h3>
<p>Aside from an attempt at humor, Wijmo makes a really bold claim:</p>
<blockquote style="clear: both;"><p>There’s is a new highly volatile element for creating websites and web apps on earth. We call the new element “Wijmo”. Wijmo is a complete kit of over 30 jQuery UI Widgets. It is an extremely dangerous mixture of jQuery, CSS3, SVG, and HTML5 that when combined become an unstoppable force on the web.</p></blockquote>
<p><span id="more-669"></span><br />
<img src="http://www.jc-designs.net/newimages/blogImages/wijmo.jpg" alt="Wijmo - jQuery UI Widgets kit" class="left" />That last line is pretty good, because it grabbed my attention and made me think, &#8220;Ok, I&#8217;m willing to see if you can back that claim up.&#8221; I then started looking at their demo page and I&#8217;ll be damned if some of it wasn&#8217;t cool. I like their calendar and graphs, which would be something I would use. There are a ton of other widget thingies included, too, like a drop-down menu, accordion, form styling, a grid, and some other things that I didn&#8217;t really care about. What impressed me was how many things they were showing you can use.</p>
<p>I then downloaded it, and checked to see the size of the js file because I couldn&#8217;t find that anywhere. Usually things like this like to boast how light/small they are in the weight department. It was fairly easy to guess why they didn&#8217;t&#8230;it weighs in at a huge by large 215k! And that is the minified version! &#8220;Ok, let&#8217;s see what else is going on before you start judging,&#8221; I thought to myself.</p>
<p>I then check the docs page for starting your first Wijmo project, and opened up the sample index page. It doesn&#8217;t say what is specifically required, so I will assume it needs all of these scripts:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/jquery-1.4.2.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/ui/jquery.ui.core.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/ui/jquery.ui.widget.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/ui/jquery.ui.position.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/ui/jquery.effects.core.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/ui/jquery.effects.blind.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/ui/jquery.effects.slide.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/ui/jquery.effects.scale.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/glob/jquery.glob.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../jQuery/glob/globinfo/jquery.glob.all.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../../jquery.wijmo.wijpopup.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span>
<span style="color: #339933;color: #439AD0;">&lt;</span>script type<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;text/javascript&quot;</span> src<span style="color: #339933;color: #439AD0;">=</span><span style="color: #3366CC;color: #439AD0;">&quot;../../jquery.wijmo.wijcalendar.js&quot;</span><span style="color: #339933;color: #439AD0;">&gt;&lt;/</span>script<span style="color: #339933;color: #439AD0;">&gt;</span></pre></div></div>

<p>HOLY CRAP! That is 12 scripts! On the sample page included with the download there are 8! I did a swift calculation and we are looking at around 560k just for the one with 8. That seems too extreme, right? Well, I had to see what the test page was doing and ran it Firefox. Well, it is running all of the open widgets (you only get half the widgets in the open version, and all of them in the licensed one &#8211; couldn&#8217;t find price). I then started eliminating scripts to see what would happen.</p>
<p>Two things popped out at me. If you want to use the graphs, you need at least 6 of those scripts: jQuery, jQueryUI, jQuery.glob (whatever the &#8216;f&#8217; that is), rapheal.js, the open wijmo, and the complete wijmo scripts. On top of that, raphael.js is a separate library. Which seems totally odd to require two different libraries to get a widget to work. Then it looks like there are some required stylesheets. All in all, that is a ton of http requests.</p>
<p>It does look like you can use only the widget script that you need, but you will still have to have a few others included to get them to work. Just after browsing though all that, I can&#8217;t say that this is a good option at all. If I were going to use a widget like what Wijmo offers, I would use <a href="http://jc-designs.net/blog/2010/06/testing-out-jquery-tools-pure-awesome/" target="_blank">jQuery Tools</a> instead. Smaller and by the looks way easier to use.</p>
<p>Thoughts?</p>
<p><strong>UPDATE: Wijmo has officially been released. Wijmo Complete has an introductory price of $499.</strong></p>
<h3>It&#8217;s all in your head!</h3>
<p><img src="http://www.jc-designs.net/newimages/blogImages/headjs.jpg" alt="Head JS - The only script in your head" class="left" />I&#8217;ve seen Head JS mentioned a few times, and my supervisor was the one that actually sent me a link to see what I thought. While it is not ready to be used in production, it is close and very cool. Basically, it loads all of your scripts in parallel so there is no page blocking. They claim that this will make your page load 100-400% times faster, and if you look at their test page, it does seem to do that. It does a lot more than that, and only weighs 2.3k. One thing I don&#8217;t like is that it says  &#8220;the only script in your head,&#8221; which to me, is not true unless they want you to write all of your extra js into the head.js file itself. Which may be the case. Anyway, calling your other js files in head is easy:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">head.<span style="color: #660066;">ready</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">&quot;jquery&quot;</span><span style="color: #339933;color: #439AD0;">,</span> <span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
	$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#container'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">fadeIn</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #CC0000;color: #439AD0;">3000</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>							  
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
&nbsp;
head.<span style="color: #660066;">js</span><span style="color: #009900;color: #439AD0;">&#40;</span>
	<span style="color: #009900;color: #439AD0;">&#123;</span>jquery<span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js?ver=1.4.1&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span>
	<span style="color: #009900;color: #439AD0;">&#123;</span>ui<span style="color: #339933;color: #439AD0;">:</span> <span style="color: #3366CC;color: #439AD0;">&quot;https://github.com/headjs/www/raw/master/content/test/jquery-ui.js&quot;</span><span style="color: #009900;color: #439AD0;">&#125;</span>
<span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>You will see two things going on above. The first part is just a stupid function using jQuery, and the second part is where you call the files. You&#8217;ll notice that the word jquery is in front of the first call. They allow you to give labels to the files so that instead of putting a url to the file itself, people in production will be able to just call &#8216;jquery&#8217; and it will use it. Obviously the labels can be anything, but it really makes it a lot easier to know which script to use. I am going to assume because of what they show on their website, that you can use multiple libraries without any worry about conflicts.</p>
<p>On top of that, Head JS comes with a bunch of other stuff to make your life easier, such as: a CSS Modernizer, HTML5 enabler, a Screen Size detector, Dynamic CSS, a CSS Router (so you can target specific pages), a Browser detector, and Javascript Feature detection. That is a lot of stuff crammed into 2.3k. I can see Head JS becoming widely used once they get everything finalized.</p>
<p><strong>UPDATE: <a href="http://doctype.tv/printing">DOCTYPE just did a video</a> explaining this better than I ever could. I recommend watching it to learn more!</strong></p>
<h3>Ending thoughts</h3>
<p>I think I have wrote enough about Wijmo, but Head JS looks extremely promising. Once they have a stable release I will be curious to see if the <a href="http://html5boilerplate.com/">HTML5 Boilerplate</a> will incorporate it. I read that the creator has looked into it, but said it isn&#8217;t ready yet to be included. Curious to see what the final outcome of that will be.</p>
<p>Some things you find out there are cool, while others suck. Either way, it is fun to find out. Let me know your thoughts on either of these, because I am very curious to read other points of view.</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=669" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2010/12/wijmo-and-headjs-reviews/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Another Simple jQuery Gallery Idea</title>
		<link>http://jc-designs.net/blog/2010/11/another-simple-jquery-gallery-idea/</link>
		<comments>http://jc-designs.net/blog/2010/11/another-simple-jquery-gallery-idea/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 03:50:48 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=636</guid>
		<description><![CDATA[Lock and Load that HTML A co-worker had asked me for some help the other day on the jQuery running his gallery. Of course, I was more than happy to help. He ran into other issues later (which he cleared up) involving a plugin, but that doesn&#8217;t really matter in this demo/tutorial. What he wanted [...]]]></description>
			<content:encoded><![CDATA[<h3>Lock and Load that HTML</h3>
<p>A co-worker had asked me for some help the other day on the jQuery running his gallery. Of course, I was more than happy to help. He ran into other issues later (which he cleared up) involving a plugin, but that doesn&#8217;t really matter in this demo/tutorial. What he wanted was to have a navigation at the top, each item pertaining to a different part of his portfolio (websites, flash work, graphic design&#8230;). Each section though had a ton of information that would increase the page load significantly if they were all loaded on the page at the same time. That ruled out putting a simple hide/show on some divs. My thought was, why don&#8217;t we put the HTML into separate files, and load them when a user clicks on one of the nav items. You can check out the gist of what was trying to be accomplished by check out the demo below.</p>
<p><a class="viewDemo" href="http://www.jc-designs.net/demo/gallery2.html">View Demo</a></p>
<p><span id="more-636"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> imageGroup <span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#holder'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageGroup1.html'</span><span style="color: #009900;color: #439AD0;">&#41;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.image1'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'active'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">;</span>
	imageGroup<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> <span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#container a'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span>e<span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
			e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#container a'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'active'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #000066; font-weight: bold;color: #439AD0;">this</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'active'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.image1'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#123;</span>$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#holder'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageGroup1.html'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
		$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.image2'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #009900;color: #439AD0;">&#123;</span>$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#holder'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'imageGroup2.html'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span><span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
	<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<h3>What its doing &#8211; and keeping it simple</h3>
<p>I&#8217;m sure there is a much more efficient way of writing the jQuery, but I was going for something simple he would be able to add to, and understand what was going on. What is going on you ask? Great question, and if you didn&#8217;t ask this article would be over.</p>
<p>The first two lines deal with loading content right off the bat. So I created a function which loads the HTML from the page &#8216;imageGroup1.html&#8217;. Just so you know what is going on, the two external HTML pages only contain images (that&#8217;s it, no html tag, no body, nothing but the img&#8217;s). You can obviously include whatever you want in those those. The second line of the first function then adds the active class to the first &#8216;a&#8217; tag, which has the class &#8216;active&#8217; on it. This gives the first nav item the roll-over state on page load, which you can see in the demo. Looking at the code above, you see the line &#8216;imageGroup();&#8217; which calls the function, because without it, those first lines don&#8217;t do anything. They will wait for a call that will never happen.</p>
<p>After that is an anonymous function (no need to name it for what we are doing here) that controls the switching of the class &#8216;active&#8217; between nav items, and the loading of HTML from different pages. First is the click event on all the &#8216;a&#8217; tags within the nav list. We prevent the default action of what &#8216;a&#8217; tags normally do, then remove the &#8216;active&#8217; class from all of them, and add it again to the specific one clicked. That moves the &#8216;active&#8217; class to whatever nav item was clicked last.</p>
<p>Next comes the actual loading of the external HTML. This is probably where a better method could be used, but we are not dealing with anything complicated here so I kept it simple. I am guessing a case switch could be used if we were dealing with a large number of items being loaded. Each of the &#8216;a&#8217; tags in the nav has a specific class, and when they are clicked, a specific HTML page gets loaded into a div with an id of &#8216;holder&#8217;. So if the first nav item is clicked, &#8216;imageGroup1.html&#8217; gets loaded into &#8216;holder&#8217;, and if the second is clicked, &#8216;imageGroup2.html&#8217; is loaded. That is all there is to it to this gallery.</p>
<h3>Final Words</h3>
<p>This is just a basic demo, so there is minimal styling going on, but think about what you can do with that. My co-worker added fancybox to it, to add some pop-ups when the images were clicked. You can add whatever the hell you want to this, like description text, fades, animations&#8230;whatever. Have fun with it, and let me know what you think!</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-" rel="nofollow"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=636" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2010/11/another-simple-jquery-gallery-idea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Thinking Outside The Box With jQuery</title>
		<link>http://jc-designs.net/blog/2010/09/thinking-outside-the-box-with-jquery/</link>
		<comments>http://jc-designs.net/blog/2010/09/thinking-outside-the-box-with-jquery/#comments</comments>
		<pubDate>Wed, 22 Sep 2010 02:59:48 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=557</guid>
		<description><![CDATA[Is it waves ahead of Flash? NOTE: Stick through to the end of the article, and I&#8217;ll give you a cool link for a reward! No, but it can still do a lot of cool crap. Today I was noodling around and somehow this idea popped into my head. Normally, at my current place of [...]]]></description>
			<content:encoded><![CDATA[<h3>Is it waves ahead of Flash?</h3>
<p><em>NOTE: Stick through to the end of the article, and I&#8217;ll give you a cool link for a reward!</em><br />
No, but it can still do a lot of cool crap. Today I was noodling around and somehow this idea popped into my head. Normally, at my current place of employment, we build animations using Flash. Butterflies fluttering around, fades and what-not, hell I even did a water ripple effect once. I thought, what if we could do some of the simple banners that are just plain fades and use jQuery instead of Flash to do everything. My initial idea was, what if a client has a photo of a beach, and he wants the stupid water to move. Could I do something in jQuery instead of having to rely on Flash?</p>
<h3>The set up</h3>
<p>My HTML for the demo is easy: a container div, 1 div with the original image, and 2 additional divs with only the water section of the image. 3 divs, 2 seperate images. The images are pretty large, because in this demo I was going for a rough effect rather than bringing the size down.</p>
<p><span id="more-557"></span><br />
The jQuery is rather simple, too. Two animations in a loop&#8230;1 on each of the &#8216;just water&#8217; images. The first animation moves it left and back, while the second moves it down and up. Here it is for you to look at:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span> waves <span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
		<span style="color: #000066; font-weight: bold;color: #439AD0;">for</span><span style="color: #009900;color: #439AD0;">&#40;</span>i<span style="color: #339933;color: #439AD0;">=</span><span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">;</span> i<span style="color: #339933;color: #439AD0;">&lt;</span><span style="color: #CC0000;color: #439AD0;">1000</span><span style="color: #339933;color: #439AD0;">;</span> i<span style="color: #339933;color: #439AD0;">++</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#two'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
				<span style="color: #3366CC;color: #439AD0;">'top'</span> <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #339933;color: #439AD0;">+</span><span style="color: #CC0000;color: #439AD0;">15</span><span style="color: #339933;color: #439AD0;">,</span>
				<span style="color: #3366CC;color: #439AD0;">'opacity'</span> <span style="color: #339933;color: #439AD0;">:</span> .2
			<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span><span style="color: #CC0000;color: #439AD0;">2000</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
				<span style="color: #3366CC;color: #439AD0;">'top'</span> <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #339933;color: #439AD0;">-</span><span style="color: #CC0000;color: #439AD0;">2</span><span style="color: #339933;color: #439AD0;">,</span>
				<span style="color: #3366CC;color: #439AD0;">'opacity'</span> <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #CC0000;color: #439AD0;">1</span>
			<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span><span style="color: #CC0000;color: #439AD0;">2000</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
			$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#three'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
				<span style="color: #3366CC;color: #439AD0;">'left'</span> <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #339933;color: #439AD0;">-</span><span style="color: #CC0000;color: #439AD0;">5</span><span style="color: #339933;color: #439AD0;">,</span>
				<span style="color: #3366CC;color: #439AD0;">'opacity'</span> <span style="color: #339933;color: #439AD0;">:</span> .2
			<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span><span style="color: #CC0000;color: #439AD0;">2000</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">animate</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#123;</span>
				<span style="color: #3366CC;color: #439AD0;">'left'</span> <span style="color: #339933;color: #439AD0;">:</span> <span style="color: #CC0000;color: #439AD0;">0</span><span style="color: #339933;color: #439AD0;">,</span>
				<span style="color: #3366CC;color: #439AD0;">'opacity'</span> <span style="color: #339933;color: #439AD0;">:</span> .6
			<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">,</span><span style="color: #CC0000;color: #439AD0;">2000</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>			
		<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">;</span>				
	<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #339933;color: #439AD0;">;</span>
	waves<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>I&#8217;m sure there is a better way to do that, but I am going for getting you thinking right now, not prettiness. I will assume you at least know enough about jQuery to understand what I am doing there, because there isn&#8217;t anything tricky or awesome going on.</p>
<p><a href="http://www.jc-designs.net/demo/waves.html">View Demo</a></p>
<h3>Thrillsville, but who really cares?</h3>
<p>The demo is more to show that you can do things you normally wouldn&#8217;t with jQuery. Sure you can build a cool slider, or drop down, or form validation, etc. The next time you have to do some little bit of animation though, maybe you will think about using jQuery instead of Flash. For instance, the butterfly thing I mentioned. All I did was create a movie clip in Flash that had different states of wing flappage. You could very easily do that with jQuery by doing a simple animation like my waves, only use an image sprite. Shift the sprite over every fraction of a second and you would have the same effect going.</p>
<p>After creating this moving water bit, I know I&#8217;ll be thinking outside the box, and see if maybe jQuery will fit the bill more easily. Please take note that I am not against Flash at all. I like using it, and there will be times where that is the only route to get a specific thing accomplished. I&#8217;m not on some crusade to get rid of it. All this was for, was to get you to think about the possibilities if you have jQuery at your disposal.</p>
<p>Now onto your reward! Check out <a href="http://www.dropmocks.com/">this link</a>, when you get there you&#8217;ll know what to do. Can&#8217;t use it in IE though, but I think they&#8217;ll get to that someday.</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=557" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2010/09/thinking-outside-the-box-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Actually Knowing What You Are Doing &#8211; jQuery Addition</title>
		<link>http://jc-designs.net/blog/2010/09/actually-knowing-what-you-are-doing-jquery-addition/</link>
		<comments>http://jc-designs.net/blog/2010/09/actually-knowing-what-you-are-doing-jquery-addition/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 03:30:10 +0000</pubDate>
		<dc:creator>jcDesigns</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://jc-designs.net/blog/?p=555</guid>
		<description><![CDATA[THAT&#8217;S why we do that There are times that we learn to do something in web development, and we do them without really knowing the reason why we do it. For instance. I learned a couple of things today about jQuery. The first thing was about return false; versus preventDefault (which I learned here). Now, [...]]]></description>
			<content:encoded><![CDATA[<h3>THAT&#8217;S why we do that</h3>
<p>There are times that we learn to do something in web development, and we do them without really knowing the reason why we do it. For instance. I learned a couple of things today about jQuery.  The first thing was about return false; versus preventDefault (which I learned <a href="http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/">here</a>). Now, I know the difference. The return false; kills event bubbling. That&#8217;s great, right? We don&#8217;t want that crap going up through the DOM. But what if you did? An example would be if you wanted to prevent a link from actually doing what the browser expects a link to do, AND have the parent div do something as well.</p>
<p><span id="more-555"></span><br />
Example &#8211; here is the html:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;color: #439AD0; font-weight: bold;">&lt;div id=&quot;myDiv&quot;&gt;
&lt;a href=&quot;http://www.google.com&quot;&gt;This is a test link.&lt;/a&gt;
&lt;div class=&quot;myClass&quot;&gt;&lt;p&gt;This is the div that should be hidden&lt;/p&gt;&lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p>Here is the CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #cc00cc;">#myDiv</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">width</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">500px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">height</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">500px</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">background</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">none</span> <span style="color: #cc00cc;">#999999</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">margin</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #933;">30px</span> <span style="color: #993333;color: #439AD0;">auto</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span>
<span style="color: #6666ff;color: #439AD0;">.redHighlight</span> <span style="color: #00AA00;color: #439AD0;">&#123;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">color</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #cc00cc;">#ff0000</span><span style="color: #00AA00;color: #439AD0;">;</span>
	<span style="color: #000000; font-weight: bold;color: #439AD0;">font-weight</span><span style="color: #00AA00;color: #439AD0;">:</span> <span style="color: #993333;color: #439AD0;">bold</span><span style="color: #00AA00;color: #439AD0;">;</span>
<span style="color: #00AA00;color: #439AD0;">&#125;</span></pre></div></div>

<p>And lastly, the jQuery:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span>document<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#myDiv a'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>		   
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.myClass'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'redHighlight'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #000066; font-weight: bold;color: #439AD0;">return</span> <span style="color: #003366; font-weight: bold;color: #439AD0;">false</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#myDiv'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>  <span style="color: #009900;color: #439AD0;">&#123;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.myClass'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>This took me some time fiddling with a demo to see if what the above linked article was saying was true. The above code, will do two things: add the class &#8216;redHighlight&#8217; to .myClass if you click the &#8216;a&#8217; tag while preventing the link to go to Google, and 2) if you click the parent of the &#8216;a&#8217; tag, &#8216;#myDiv&#8217;, it will hide the div with the class &#8216;myClass&#8217;.</p>
<p>HERE though is what I learned. IF you click on the &#8216;a&#8217; tag, it WILL add the class &#8216;redHighlight&#8217;. What it won&#8217;t do, is hide the div &#8216;.myClass&#8217;, even though it is within &#8216;#myDiv&#8217;. This is because the return false; prevents the click event to bubble up to its parent, therefore the click that is supposed to hide &#8216;myClass&#8217; never fires. View the demo below to see what I am talking about, but click on the link, then refresh and click on the gray box.</p>
<p><a href="http://www.jc-designs.net/demo/return.html">View Demo</a></p>
<p>NOW change return false; to preventDefault, so it looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span>document<span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#myDiv a'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span>e<span style="color: #009900;color: #439AD0;">&#41;</span> <span style="color: #009900;color: #439AD0;">&#123;</span>
e.<span style="color: #660066;">preventDefault</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.myClass'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'redHighlight'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#myDiv'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #003366; font-weight: bold;color: #439AD0;">function</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span>  <span style="color: #009900;color: #439AD0;">&#123;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'.myClass'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
<span style="color: #009900;color: #439AD0;">&#125;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p><a href="http://www.jc-designs.net/demo/return2.html">View Demo</a></p>
<p>View the above demo, and again, click on the link to see what happens, refresh and click on the surrounding gray box. You will see the difference. The first demo changes the color, the second demo hides the the &#8216;myClass&#8217; div. Why does it happen differently with preventDefault? Because the bubbling effect goes up to the parent div. Meaning the click event bubbles up to the parent div &#8216;myDiv&#8217; and fires off the event to hide the div &#8216;myClass&#8217;.</p>
<p>PRETTY DAMN AWESOME! I knew before what event propagation meant, but I never really understood the effect it would have. Now I do because of the linked article. So remember&#8230;return false will kill event bubbling, prevents the default behavior, and stops callback execution and returns immediately when called. The preventDefault() only prevents the default behavior.</p>
<h3>Caching the location of your selection</h3>
<p>The second thing I learned doesn&#8217;t actually effect how I write my code. This is more of a &#8220;I didn&#8217;t know that..&#8221; type of thing. Do you know why you use variables when you are writing jQuery? If you answered &#8220;Because it is easier to write the variable name than writing the damn thing out everytime&#8221;&#8230;well you are right. BUT there is another reason. When you write a variable like:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;"><span style="color: #003366; font-weight: bold;color: #439AD0;">var</span> awesome <span style="color: #339933;color: #439AD0;">=</span> $<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#pfarmFlavorBlastedGoldfish'</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>You are caching the location of that selection. If you wrote it out each time you needed it, like so:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;color: #439AD0; font-weight: bold;">$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#pfarmFlavorBlastedGoldfish'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#pfarmFlavorBlastedGoldfish'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span>
$<span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #3366CC;color: #439AD0;">'#pfarmFlavorBlastedGoldfish'</span><span style="color: #009900;color: #439AD0;">&#41;</span>.<span style="color: #660066;">eatthehelloutthem</span><span style="color: #009900;color: #439AD0;">&#40;</span><span style="color: #009900;color: #439AD0;">&#41;</span><span style="color: #339933;color: #439AD0;">;</span></pre></div></div>

<p>Yes I am eating these addicting things&#8230;but anyway, the above is repeatedly querying the DOM and creating multiple jQuery objects.</p>
<h3>Final words</h3>
<p>Sometimes we do things just because we read how to do them, but not the actual WHY we are doing it a certain way. I love learning the reasons behind things that I do, such as the two examples I&#8217;ve written about tonight. It strengthens my knowledge of the subject, in this case jQuery, and makes it easier to explain to someone else why it is I am doing something.</p>
<p>A VERY big shout out to Doug Neiner at <a href="http://fuelyourcoding.com/jquery-events-stop-misusing-return-false/">Fuel Your Coding</a> for that article. It taught me a lot. And a thanks to <a href="http://net.tutsplus.com/tutorials/javascript-ajax/14-helpful-jquery-tricks-notes-and-best-practices">net.tutsplus.com</a> for a bunch of helpful hints.</p>
<div class="gator">
<a  href="http://secure.hostgator.com/~affiliat/cgi-bin/affiliates/clickthru.cgi?id=jcDesigns-"><img src="http://tracking.hostgator.com/img/Shared/468x60.gif" border=0></a></p>
<p>Coupon Code: webmachine</p>
</div>
 <img src="http://jc-designs.net/blog/wp-content/plugins/wordpress-feed-statistics/feed-statistics.php?view=1&post_id=555" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://jc-designs.net/blog/2010/09/actually-knowing-what-you-are-doing-jquery-addition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

