<?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; jquery</title>
	<atom:link href="http://johnmc.co/llum/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnmc.co/llum</link>
	<description>Muddling through since 1980</description>
	<lastBuildDate>Sat, 11 Sep 2010 11:59:14 +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>jQuery 1.4 Reference Guide &#8211; reviewed</title>
		<link>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/</link>
		<comments>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/#comments</comments>
		<pubDate>Wed, 24 Mar 2010 19:24:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[book review]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=116</guid>
		<description><![CDATA[Packt Publishing were kind enough to send me a copy of the jQuery 1.4 Reference Guide, by Jonathan Chaffer and Karl Swedberg. The book is intended to be a comprehensive reference for the library, aimed at intermediate to advanced readers. The first point I should make about this book is that it is not intended [...]]]></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%2Fjquery-1-4-reference-guide-reviewed%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fjquery-1-4-reference-guide-reviewed%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Packt Publishing were kind enough to send me a copy of the <a href="http://www.packtpub.com/jquery-1-4-reference-guide/book">jQuery 1.4 Reference Guide</a>, by Jonathan Chaffer and Karl Swedberg. The book is intended to be a comprehensive reference for the library, aimed at intermediate to advanced readers.</p>
<p>The first point I should make about this book is that it is not intended for users who are new to the jQuery library &#8211; this is not a book full of tutorials. If that&#8217;s what you&#8217;re looking for, you should check out <a href="http://www.packtpub.com/learning-jquery-1.3/book">Learning jQuery 1.3</a> instead, by the same authors.</p>
<p>The book is organised into eleven chapters, covering (amongst other things) selectors, DOM traversal and manipulation, events, effects, and AJAX. The whole library is covered (as you would expect from a reference guide).</p>
<p>Each method in the library has its parameters documented. This is surprisingly helpful &#8211; many jQuery methods can be overloaded for various purposes, and this feature of the book is a great help towards learning the possibilities of each method. In fact, one of the take-home points for me was that many methods now support anonymous functions as parameters, offering lots of flexibility.</p>
<p>Next, a bare bones code sample is shown to demonstrate the method. It is followed  by an explanation of the code sample, along with any &#8216;gotchas&#8217; or quirks that you might experience. Multiple examples of code are shown where there might be different ways to use a particular method. The book really is quite exhaustive, and from that point of view offers great value for money.</p>
<p>Although this book works really well as a reference book, the surprise for me was that it didn&#8217;t <em>just </em>work well as a reference book<em>. </em>Reading through the book, I picked up a lot of hints and tips that will almost certainly change how I use jQuery. For example, I realised that my knowledge of selectors was sorely lacking. (Partly this was because I&#8217;d never bothered to learn the CSS3 selectors properly, but jQuery gives me a reason!)</p>
<p>Another excellent chapter for me was the last one, regarding plug in architecture. The structure of this chapter was a little different, basically walking the reader through the process of creating various types of plugin. Like the best technical books, this chapter actually inspired me to put the book down and write some code &#8211; surely a sign that it was doing its job properly!</p>
<p>It&#8217;s worthwhile to note that if you are considering purchasing a copy of this book, Packt will make a contribution to the jQuery project for every copy sold; so in buying this book, you&#8217;ll increase your own knowledge, and you&#8217;ll be directly helping the jQuery project too. For me, that&#8217;s one of the best reasons to buy.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/jquery-1-4-reference-guide-reviewed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dan Wellman&#8217;s jQuery UI 1.7 reviewed</title>
		<link>http://johnmc.co/llum/dan-wellmans-jquery-ui-1-7-reviewed/</link>
		<comments>http://johnmc.co/llum/dan-wellmans-jquery-ui-1-7-reviewed/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 20:27:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[book review]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=98</guid>
		<description><![CDATA[I recently finished reading Dan Wellman&#8216;s book, jQuery UI 1.7 &#8211; The User Interface Library for jQuery. But with the imminent realease of version 1.8 of the popular interface library, is this book still relevant? In my opinion,  it is. This book is recommended for beginner to intermediate users of jQuery UI, and it hits the mark [...]]]></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%2Fdan-wellmans-jquery-ui-1-7-reviewed%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fdan-wellmans-jquery-ui-1-7-reviewed%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://johnmccollum.co.uk/wp-content/uploads/2010/03/ui17.png"><img class="alignright size-full wp-image-105" title="ui17" src="http://johnmccollum.co.uk/wp-content/uploads/2010/03/ui17.png" alt="" width="100" height="123" /></a>I recently finished reading <a href="http://www.danwellman.co.uk/">Dan Wellman</a>&#8216;s book, <a href="http://www.packtpub.com/user-interface-library-for-jquery-ui-1-7">jQuery UI 1.7 &#8211; The User Interface Library for jQuery</a>. But with the imminent realease of version 1.8 of the popular interface library, is this book still relevant? In my opinion,  it is.</p>
<p>This book is recommended for beginner to intermediate users of jQuery UI, and it hits the mark perfectly for its intended audience. There&#8217;s a chapter for each of the high and low level widgets, as well as the CSS and effects frameworks. Each chapter is structured to follow a logical pattern, and Dan&#8217;s clear writing style means that the code and text is easy to follow.</p>
<p>Each chapter starts with a basic example, and gradually adds more and more options to show the flexibility and power of the framework. The text is supported by numerous code samples, which can be downloaded from <a href="http://www.packtpub.com/">Packt Publishing</a>&#8216;s support site. Finally, each chapter ends with an imaginative, more advanced use of the library. One chapter showcases jQuery UI&#8217;s drag and drop functionality with a game, for example. These examples really bring the code to life, and inspire you to open your favourite text editor and start coding!</p>
<p>The most obvious omission from this book (in fact, the only one worth mentioning, really) is the lack of a section on writing your own plugins for jQuery UI. Dan obviously feels the same way, because he&#8217;s written a <a href="http://net.tutsplus.com/tutorials/javascript-ajax/coding-your-first-jquery-ui-plugin/">tutorial on the subject here</a>, and something like this is promised for the next update of the book. If this more advanced topic is something that interests you, you might want to wait for the next version of the book.</p>
<p>Alternatively, if your knowledge of jQuery UI is at the other end of the spectrum, there&#8217;s no reason at all not to go ahead and buy the current version. The book focuses on the common features of each widget (for example the destroy, enable, and disable methods) so that you can easily adapt to the new components as they appear.</p>
<p>If you&#8217;re somewhere between the two camps, as I was, then this book will consolidate your knowledge and give you lots of inspiration to use the parts of the library you might not have touched on yet. And that, for me, was worth the cover price alone.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/dan-wellmans-jquery-ui-1-7-reviewed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting Prototype&#8217;s Ajax.PeriodicalUpdater to jQuery</title>
		<link>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/</link>
		<comments>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 21:54:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=84</guid>
		<description><![CDATA[One of the things I missed when switching from Prototype to jQuery was the former&#8217;s Ajax.PeriodicalUpdater function. It is used to provide a &#8216;decay&#8217; mechanism for ajax calls, making them less and less frequent if the retrieved content doesn&#8217;t change inbetween calls. It can be a seriously useful piece of functionality. I took a chatroom [...]]]></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%2Fconverting-prototypes-ajaxperiodicalupdater-to-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fconverting-prototypes-ajaxperiodicalupdater-to-jquery%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>One of the things I missed when switching from <a href="http://prototypejs.org">Prototype</a> to <a href="http://jquery.com">jQuery</a> was the former&#8217;s <a href="http://www.prototypejs.org/api/ajax/periodicalUpdater">Ajax.PeriodicalUpdater</a> function. It is used to provide a &#8216;decay&#8217; mechanism for ajax calls, making them less and less frequent if the retrieved content doesn&#8217;t change inbetween calls.</p>
<p>It can be a seriously useful piece of functionality. I took a chatroom that was polling every second and using an entire CPU core (50% usage!) and reduced it to 2-3% using this method. There were also errors retrieving content because sometimes the responses would take longer than a second to come back!</p>
<p>The problem is, there really isn&#8217;t a similar piece of functionality in jQuery.</p>
<p>So here it is! The script checks the returned data against previously received data, and increases the time between calls if it hasn&#8217;t changed.</p>
<p>I&#8217;d be interested in your comments. Would it be useful to turn this into a plugin?</p>
<p><a href="http://johnmccollum.co.uk/decay">View the demonstration here.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/converting-prototypes-ajaxperiodicalupdater-to-jquery/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using JSON to access the Twitter search API</title>
		<link>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/</link>
		<comments>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 09:35:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=81</guid>
		<description><![CDATA[Steve Reynolds recently wrote a blog post showing how to access the twitter search API using PHP, cURL, and JQuery. Steve used JQuery to post to a page on his server, which then cURLed in search results for a given term. This approach is often necessary to get avoid the issue of cross domain ajax [...]]]></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%2Fusing-json-to-access-the-twitter-search-api%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fusing-json-to-access-the-twitter-search-api%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.reynoldsftw.com/">Steve Reynolds</a> recently wrote a blog post showing <a href="http://www.reynoldsftw.com/2009/02/using-jquery-php-ajax-with-the-twitter-api/">how to access the twitter search API using PHP, cURL, and JQuery</a>.</p>
<p>Steve used JQuery to post to a page on his server, which then cURLed in search results for a given term. This approach is often necessary to get avoid the issue of cross domain ajax calls.</p>
<p>While this approach works well, there&#8217;s an even easier way to go about it &#8211; $.getJSON!</p>
<p>There are two main advantages to this approach:</p>
<ul>
<li>Server side technology isn&#8217;t an issue. You don&#8217;t have to rely on PHP, cURL, firewalls, anything like that. It will even work on a static HTML page!</li>
<li>All the work is done on the client&#8217;s browser &#8211; saving precious bandwidth! This could be important on busy sites.</li>
</ul>
<p>I&#8217;ve knocked up a quick-and-dirty demonstration of this concept. If a name doesn&#8217;t already exist for this methodology, my vote goes for JAJA (Javascript and JSON, asynchronous!)</p>
<p><a href="http://johnmccollum.co.uk/twitterjson/">View the demonstration here!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/using-json-to-access-the-twitter-search-api/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Select multi lists suck!</title>
		<link>http://johnmc.co/llum/select-multi-lists-suck/</link>
		<comments>http://johnmc.co/llum/select-multi-lists-suck/#comments</comments>
		<pubDate>Fri, 28 Nov 2008 22:13:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[select lists]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=73</guid>
		<description><![CDATA[I was recently involved in a project where there were two multi-select lists involved, with a big number of options &#8211; around 300 in each. These things are a usability nightmare: The user has to ctrl-click to select multiple options (&#8216;where&#8217;s the central key?&#8217;) A stray click will unselect everything already selected (Critically important on [...]]]></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%2Fselect-multi-lists-suck%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fselect-multi-lists-suck%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>I was recently involved in a project where there were two multi-select lists involved, with a big number of options &#8211; around 300 in each.</p>
<p>These things are a usability nightmare:</p>
<ul>
<li>The user has to ctrl-click to select multiple options (&#8216;where&#8217;s the central key?&#8217;)</li>
<li>A stray click will unselect everything already selected (Critically important on a site sign-up form)</li>
<li>They are just plain ugly</li>
</ul>
<p>So the workarounds I&#8217;ve been trialling?</p>
<p><a href="http://abeautifulsite.net/notebook/62">Jquery multiselect plugin</a> &#8211; Very nice plugin that solves all three of the problems above. One problem however &#8211; it was taking over a minute for my page to load in Firefox!</p>
<p>Interestingly, Chrome displayed the page in under 5 seconds. Guess that new javascript engine is a fast as they say&#8230;</p>
<p><a href="http://johnmccollum.co.uk/select.html">Half-assed Jquery solution I cobbled together for fun</a> &#8211; This lets the user use a single click instead of a control click on multi-select lists. Solves problem one and two, problem three would still need someone with more artistic leanings working on it. Oh, and it doesn&#8217;t work in IE. Told you it was half-assed.</p>
<p>Current favourite option &#8211; A div with overflow hidden, full of checkboxes. Sort of solves the main problems, but still not ideal.</p>
<p>How would you deal with this interface problem? I&#8217;d love to hear your suggestions.</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/select-multi-lists-suck/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to build search into your site with JQuery and Yahoo!</title>
		<link>http://johnmc.co/llum/how-to-build-search-into-your-site-with-jquery-and-yahoo/</link>
		<comments>http://johnmc.co/llum/how-to-build-search-into-your-site-with-jquery-and-yahoo/#comments</comments>
		<pubDate>Thu, 31 Jul 2008 21:06:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AJAX]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[Search]]></category>
		<category><![CDATA[Yahoo]]></category>

		<guid isPermaLink="false">http://johnmccollum.co.uk/?p=36</guid>
		<description><![CDATA[Yahoo have a hard time fighting off the image of being bridesmaid to Google&#8217;s bride. However, they have a decided knack for turning out really cool developer toys! For example, check out the Yahoo User Interface library, Yahoo Pipes, or their latest baby, Yahoo BOSS. Short for &#8216;Build your Own Search Service&#8217;, Yahoo have pretty [...]]]></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%2Fhow-to-build-search-into-your-site-with-jquery-and-yahoo%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjohnmc.co%2Fllum%2Fhow-to-build-search-into-your-site-with-jquery-and-yahoo%2F&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Yahoo have a hard time fighting off the image of being bridesmaid to Google&#8217;s bride. However, they have a decided knack for turning out really cool developer toys! For example, check out the <a href="http://developer.yahoo.com/yui/">Yahoo User Interface library</a>, <a href="http://pipes.yahoo.com/pipes/">Yahoo Pipes</a>, or their latest baby, <a href="http://developer.yahoo.com/search/boss/">Yahoo BOSS</a>.</p>
<p>Short for &#8216;Build your Own Search Service&#8217;, Yahoo have pretty much opened up their entire search service via an API. With an unrestricted number of queries, and complete control over presentation of results, you can really go to town with this one!</p>
<p>Getting started is easy; simply get yourself an <a href="http://developer.yahoo.com/wsregapp/">API key here</a>. Go on, I&#8217;ll wait.</p>
<p>With that done, anyone with basic knowledge of <a href="http://johnmccollum.co.uk/category/php/">PHP</a> and <a href="http://johnmccollum.co.uk/category/jquery/">JQuery</a> can easily build a search application!</p>
<p><a href="http://johnmccollum.co.uk/boss/">Check out my demonstration here.</a></p>
<p>There are two pages involved in this demonstration. The first page displays the form, and contains the necessary JQuery code to fire off an AJAX request to the second page. The second page takes the posted value, fires off a request to the API, and returns the result.</p>
<p>Without further ado, here&#8217;s the JQuery:<br />
<pre><pre>&nbsp;&nbsp;&nbsp;&nbsp;$(document).ready(function(){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;#results&#039;).hide();

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;#search&#039;).click(function(){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;#results&#039;).hide();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;searchterm = $(&#039;#searchterm&#039;).val();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$.post(&#039;getresult.php&#039;, {query: searchterm}, function(data){
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(&#039;#results&#039;).html(data).show(&#039;slow&#039;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})
&nbsp;&nbsp;&nbsp;&nbsp;})</pre></pre><br />
Nothing too horrendous here; hide the results division, grab the term to be searched for, fire off an AJAX request, and put the returned data in the results div. Show it slloooooowly. <img src='http://johnmc.co/llum/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The code in &#8216;getresult.php&#8217; isn&#8217;t much more complex; <a href="http://johnmccollum.co.uk/boss/getresult.txt">you can see it here.</a></p>
<p>That&#8217;s all there is to it! (At least for this very basic example.)</p>
<p>Once again, <a href="http://johnmccollum.co.uk/boss/">you can see a demonstration here</a>.</p>
<p>I&#8217;m sure there must be loads of ideas for mashups out there; let&#8217;s hear some of your thoughts!</p>
]]></content:encoded>
			<wfw:commentRss>http://johnmc.co/llum/how-to-build-search-into-your-site-with-jquery-and-yahoo/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<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>

