<?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>John McCollum &#187; CSS</title>
	<atom:link href="http://johnmc.co/llum/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnmc.co/llum</link>
	<description>Muddling through since 1980</description>
	<lastBuildDate>Thu, 02 Sep 2010 21:12:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Simple Jquery and CSS menu</title>
		<link>http://johnmc.co/llum/simple-jquery-and-css-menu/</link>
		<comments>http://johnmc.co/llum/simple-jquery-and-css-menu/#comments</comments>
		<pubDate>Sun, 13 Jul 2008 09:57:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[Menu]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=18</guid>
		<description><![CDATA[I&#8217;ve had some fun this weekend tinkering with Jquery. It&#8217;s taken me a long time to get round to playing with this library, having thrown my eggs in the Prototype / Scriptaculous basket, but after some experimentation, I wish I&#8217;d done it sooner! I have to admit; the syntax is nicer, much simpler (no more [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fsimple-jquery-and-css-menu%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fsimple-jquery-and-css-menu%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I&#8217;ve had some fun this weekend tinkering with <a href="http://jquery.com">Jquery</a>. It&#8217;s taken me a long time to get round to playing with this library, having thrown my eggs in the <a href="http://prototype.org">Prototype</a> / <a href="http://script.aculo.us">Scriptaculous</a> basket, but after some experimentation, I wish I&#8217;d done it sooner!</p>
<p>I have to admit; the syntax is nicer, much simpler (no more $$(&#8216;selector&#8217;)) and the documentation seems better. Jquery is also lightweight and fast.</p>
<p>To celebrate my switchover, here&#8217;s a very simple <a href="http://johnmccollum.co.uk/jquerymenu.html">Jquery menu demonstration</a>!</p>
<p>Let&#8217;s start off with the HTML:<br />
<pre><pre>
&lt;div id=&quot;”content”&quot;&gt;
&lt;ul id=&quot;”menu”&quot;&gt;
&nbsp;&nbsp;&lt;li class=&quot;”starter”&amp;gt;menu&quot;&gt;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;”#”&quot;&gt;home&lt;/a&gt;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;”#”&quot;&gt;about us&lt;/a&gt;&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;a href=”#”&amp;gt;portfolio&lt;/li&gt;
&nbsp;&nbsp;&lt;li&gt;&lt;a href=&quot;”#”&quot;&gt;contact us&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;</pre></pre><br />
It doesn&#8217;t get much simpler than this! An ordered list, ready for styling. Not much to see here. Here comes the javascript:<br />
<pre><pre>$(document).ready(function(){
&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).hide();

&nbsp;&nbsp;$(&quot;li.starter&quot;).click(function(){
&nbsp;&nbsp;&nbsp;&nbsp;if($(&quot;li:not(:first)&quot;).is(&quot;:visible&quot;)){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).fadeOut(&quot;fast&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;}else{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).fadeIn(&quot;fast&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;}
&nbsp;&nbsp;})
})</pre></pre><br />
Eek! Slightly more complicated. Let&#8217;s walk through it.<br />
<pre>$(document).ready(function(){</pre><br />
Before we do anything, we make sure that the DOM is ready for manipulation. This has a handy side effect, when we see the next line:<br />
<pre>$(&quot;li:not(:first)&quot;).hide();</pre><br />
This piece of code looks for all the &#8216;li&#8217; elements in the page (disregarding the first one) and hides them, using display:none. The great thing is, since we&#8217;re doing this within $(document).ready, users with javascript switched off will still see the menu!<br />
<pre>$(&quot;li.starter&quot;).click(function(){</pre><br />
This tells the browser to look out for any clicks on the li.starter element, and use the next bit of code to handle it.<br />
<pre><pre>if($(&quot;li:not(:first)&quot;).is(&quot;:visible&quot;)){
&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).fadeOut(&quot;fast&quot;);
}else{
&nbsp;&nbsp;&nbsp;&nbsp;$(&quot;li:not(:first)&quot;).fadeIn(&quot;fast&quot;);
}</pre></pre><br />
This part checks to see if the list items are visible, and shows them or hides them as appropriate.</p>
<p>You can see the full <a href="http://johnmccollum.co.uk/jquerymenu.html">demonstration here</a>, with comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/simple-jquery-and-css-menu/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
