<?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>ReadyState4 &#187; jQuery</title>
	<atom:link href="http://readystate4.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://readystate4.com</link>
	<description>JavaScript, Web Development, Ruby, and Technology.</description>
	<lastBuildDate>Fri, 04 Jun 2010 19:42:44 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery comes to WhiteHouse.gov</title>
		<link>http://readystate4.com/2009/01/20/jquery-comes-to-whitehousegov/</link>
		<comments>http://readystate4.com/2009/01/20/jquery-comes-to-whitehousegov/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 17:59:52 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://readystate4.com/2009/01/20/jquery-comes-to-whitehousegov/</guid>
		<description><![CDATA[
Today the new WhiteHouse.gov launched and although it isn&#8217;t exactly XHTML compliant it beats the pants off of most government websites and follows along with the new President&#8217;s plans of deploying a modern communications infrastructure (it&#8217;s also using jQuery and jQuery.thickbox as noted above). 
Copy on the new site explains: &#8220;WhiteHouse.gov will be a central [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://readystate4.com/images/blog/whitehouse.gov-large.jpg"><img src="http://readystate4.com/images/blog/whitehouse.gov-small.jpg" /></a><br />
Today the new WhiteHouse.gov launched and although it isn&#8217;t exactly XHTML compliant it beats the pants off of most government websites and follows along with the new President&#8217;s plans of deploying a modern communications infrastructure (it&#8217;s also using jQuery and jQuery.thickbox as noted above). </p>
<p>Copy on the new site explains: &#8220;WhiteHouse.gov will be a central part of President Obama&#8217;s pledge to make his the most transparent and accountable administration in American history.&#8221;</p>
<p>Regarding Technology, Obama has already talked about:</p>
<ul>
<li>protecting the openness of the internet.</li>
<li>supporting the principle of network neutrality to preserve the benefits of open competition on the internet.</li>
<li>deploying a modern communications infrastructure.</li>
<li>getting true broadband to every community in America.</li>
</ul>
<p>Here&#8217;s looking at a tech-positive presidency!</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2009/01/20/jquery-comes-to-whitehousegov/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Improve your jQuery &#8211; 25 excellent tips</title>
		<link>http://readystate4.com/2008/12/16/improve-your-jquery-25-excellent-tips/</link>
		<comments>http://readystate4.com/2008/12/16/improve-your-jquery-25-excellent-tips/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 01:23:04 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/12/16/improve-your-jquery-25-excellent-tips/</guid>
		<description><![CDATA[
Here&#8217;s a nice write-up by Jon Hobbs-Smith at tvidesign.com detailing 25 tips on using jQuery as well as regular JavaScript advice. Most of these tips probably aren&#8217;t anything new for the advanced jQuery user (Jon considers himself intermediate, I think that&#8217;s modest), however I love lists like this because there&#8217;s a treasure trove worth of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx"><img src="http://readystate4.com/images/blog/tvidesign_banner.jpg" style="padding-left: 0px;" /></a><br />
Here&#8217;s a nice write-up by Jon Hobbs-Smith at tvidesign.com detailing <a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx">25 tips on using jQuery</a> as well as regular JavaScript advice. Most of these tips probably aren&#8217;t anything new for the advanced jQuery user (Jon considers himself intermediate, I think that&#8217;s modest), however I love lists like this because there&#8217;s a treasure trove worth of experience being shared. Altruism at it&#8217;s best!</p>
<p>I plan on writing more entries on my own tips and tricks with JavaScript and jQuery as well as my methods of debugging in various browsers, compression techniques, etc., but in the meantime, I&#8217;ll just comment on Jon&#8217;s list: </p>
<p><strong>2. Use a [jQuery] cheat sheet</strong></p>
<p>I think <a href="http://visualjquery.com/">Visual jQuery</a> is all you need. And now that there&#8217;s live search and clickable examples it&#8217;s even better.</p>
<p><strong>3. Combine all your scripts and minify them</strong></p>
<p>Dead Edward&#8217;s packer is awesome for minifying, but before I do that, I like to run my code through <a href="http://www.jslint.com/">jSlint</a> to make sure it&#8217;s all valid. I ignore line-break errors as I don&#8217;t agree in many cases that it&#8217;s an issue.</p>
<p>Additionally, when I work on large JS codebases with a lot of other people who may not code as strictly as I do, I like to use <a href="http://www.crockford.com/javascript/jsmin.html">JSmin</a> on the minimal setting (cut-and-paste version <a href="http://fmarcia.info/jsmin/test.html">here</a>). The compression benefit is only slightly less and it preserves single linefeeds preventing JS errors where people forgot to end their statements with a semicolon. It also makes the code easier to read and debug in a production enviornment—great for the times you want the benefits of minification without the side effect of obfuscation.</p>
<p><strong>5. Keep selection operations to a minimum by caching</strong></p>
<p>I just wanted to comment in Ron&#8217;s example where he used:</p>

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

<p>First, if I ever reference a jQuery collection in my scripts, I like to append the dollar sign character to the beginning of the variable name to signify that it is, in fact, a jQuery collection:</p>

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

<p>It&#8217;s a lot more helpful when you access that variable further down the road and don&#8217;t have to question whether it&#8217;s a jQuery wrapped set, an actual HTML element, or something else.</p>
<p>Secondly, whether you&#8217;re using a JS lib or not, I would never search for an HTML collection by class name alone; What the JavaScript engine is doing in the background is looping through every single element on the page which is very intensive. It would be better to find the closest parent container first or search by specific tag name(s):</p>
<p>Good:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> $myList <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'ul.myList'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//added benefit of knowing the type of element you'll</span>
<span style="color: #006600; font-style: italic;">// receive</span></pre></div></div>

<p>Better:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> $myList <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#closest_parent_id .myList'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// searching the children of a parent</span>
<span style="color: #006600; font-style: italic;">// container instead of all the elements on the page</span></pre></div></div>

<p>Best:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> $myList <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#closest_parent_id ul.myList'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// combination of both above</span></pre></div></div>

<p><strong>19. Use noconflict to rename the jquery object when using other frameworks</strong><br />
<strong>22. How to check if an element exists[...]</strong></p>
<p>As I&#8217;ve probably mentioned before, I always like to use <code>noConflict()</code> in all my projects. I move jQuery to the $j namespace and save <code>$</code> for a shorthand reference to <code>document.getElementById</code> &#8211; I think it&#8217;s what most js developers expect and <code>if($('myDiv))</code> is a lot simpler to write out than <code>if($('#myDiv).length !== 0)</code>  or even <code>if($('#myDiv).length)</code>.</p>
<p>Thanks for the link <a href="http://www.insecureweb.com/">Bryan</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/12/16/improve-your-jquery-25-excellent-tips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Blogging live from jQuery Camp 2008 (@MIT in Boston)</title>
		<link>http://readystate4.com/2008/09/28/blogging-live-from-jquery-camp-2008-mit-in-boston/</link>
		<comments>http://readystate4.com/2008/09/28/blogging-live-from-jquery-camp-2008-mit-in-boston/#comments</comments>
		<pubDate>Sun, 28 Sep 2008 19:02:50 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/09/28/blogging-live-from-jquery-camp-2008-mit-in-boston/</guid>
		<description><![CDATA[ So far it&#8217;s been great! Good food, good talks. Here&#8217;s the full topic list. (scroll down to the middle of the page)
Took some vids until my camera died, more to come, once I convert &#8216;em and upload &#8216;em. Here&#8217;s the most interesting things I learned so far:
jQuery:

jQuery does do DOM caching! It listens for [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.readystate4.com/images/blog/jquery.gif" style="float: right; padding: 0 0 5px 5px;" /> So far it&#8217;s been great! Good food, good talks. <a href="http://jquery.com/blog/2008/08/31/jquery-conference-2008-agenda/">Here&#8217;s the full topic list.</a> (scroll down to the middle of the page)</p>
<p>Took some <a href="http://www.youtube.com/watch?v=V-MHHtw6kPY">vids</a> until my camera died, more to come, once I convert &#8216;em and upload &#8216;em. Here&#8217;s the most interesting things I learned so far:</p>
<p>jQuery:</p>
<ul>
<li>jQuery <i>does</i> do DOM caching! It listens for DOM-modified events to clear it&#8217;s internal cache.</li>
<li>That random jquery[<i>random numbers</i>] variable that gets added to the window object is to uniquely identify the jQ instantiation (so you can do things like run multiple instances of jQuery on the same page).</li>
<li>I knew about <a href="http://docs.jquery.com/Traversing/end">.end()</a> but <a href="http://docs.jquery.com/Traversing/andSelf">.andSelf()</a>? Cool!</li>
<li>Nokia and Microsoft join the jQuery camp. Nokia will have jQuery built into their phones (they have some browser-like app environment) $M will have it in their VS/ASP.NET and all future versions of Visual Studio will come with it going foward. <a href="http://jquery.com/blog/2008/09/28/jquery-microsoft-nokia/">link</a> <a href="http://weblogs.asp.net/scottgu/archive/2008/09/28/jquery-and-microsoft.aspx">link</a>.</li>
<li>jQuery is planning to be the first library that doesn&#8217;t use any browser sniffing. They are going to use a &#8220;quirk check&#8221; method of creating some elements that aren&#8217;t added to the page that check for things like if white space gets removed when created an element that starts with a space (IE bug) and others. This way they don&#8217;t have to be constantly updating for new browsers.
<li>John&#8217;s working on a cool new DOM selector API called Sizzle that&#8217;s supposed to be a lot faster. It works by search for the last element in your query up. For example <code>$('div p');</code> would look for all p elements on the page that has a parent div element.</li>
<li>You can use create a namespace when binding events. For example <code>$('#foo').bind('click.bar', func);</code> so it&#8217;s easy to unbind later, and you can encapsulate your events for your own plugins to prevent conflicts.  You can also create your own custom events like <code>$('#foo').bind('apple', func);</code>  and trigger them using <code>$('#foo').trigger('apple');</code> .</li>
<li><code>$('#element').data();</code> lets you bind data to DOM elements (see Data Cache under Internals section <a href="http://remysharp.com/visual-jquery/">here</a>.) Since you can&#8217;t really bind an object to a DOM node jQuery assigns it a random key behind the scenes which it references. This is really handly for storing all kinds of data.
</ul>
<p>jQuery UI:<br />
- Uses the data method above A LOT.<br />
- Lots of enhancements, most interestingly, with drag-and-drop which detects floated elements and allows you to have draggable lists within draggable lists.<br />
- jQuery UI team also working on some experimental stuff for Webkit only (iPhone / Safari / Chrome).<br />
- Theming jQuery UI with <a href="http://ui.jquery.com/themeroller">ThemeRoller</a></p>
<p>Other:<br />
- I&#8217;ve been using this really old but handy site as a jQ reference: <a href="http://visualjquery.com/1.1.2.html">http://visualjquery.com/1.1.2.html</a> made by Yehuda Katz (also a speaker). Asking around on the conference IRC chan I found there&#8217;s a much newer / improved one at <a href="http://remysharp.com/visual-jquery/">http://remysharp.com/visual-jquery/</a> by Remy Sharp. They&#8217;re going to try to update the prior site with the latter.<br />
- Canvas tag is pretty basic but sweet. John Resig gave a whole presentation on it since the using jQuery with Firefox plugins couldn&#8217;t make it.</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/09/28/blogging-live-from-jquery-camp-2008-mit-in-boston/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inject jQuery into any page / A better jQuery bookmarklet</title>
		<link>http://readystate4.com/2008/07/08/inject-jquery-into-any-page-a-better-jquery-bookmarklet/</link>
		<comments>http://readystate4.com/2008/07/08/inject-jquery-into-any-page-a-better-jquery-bookmarklet/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 22:53:32 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/07/08/inject-jquery-into-any-page-a-better-jquery-bookmarklet/</guid>
		<description><![CDATA[The problem
I had to find out the language codes of all supported languages in TinyMCE (this page), but unfortunately, they were only listed in the actual download link for each file. A quick sprinkle of jQuery code in my Firebug console would have returned me a list easily but this page didn&#8217;t have it &#8211; [...]]]></description>
			<content:encoded><![CDATA[<h3>The problem</h3>
<p>I had to find out the language codes of all supported languages in TinyMCE (<a href="http://services.moxiecode.com/i18n/">this page</a>), but unfortunately, they were only listed in the actual download link for each file. A quick sprinkle of jQuery code in my Firebug console would have returned me a list easily but this page didn&#8217;t have it &#8211; which lead me to consider making a bookmarklet to add jQuery on any page. </p>
<h3>The solution:</h3>
<p>My wonderful coworker Bryan told me immediately about a simple bookmarklet that does the above called <a href="http://www.google.com/search?hl=en&#038;client=firefox-a&#038;rls=org.mozilla%3Aen-US%3Aofficial&#038;hs=Dty&#038;q=jQuerify&#038;btnG=Search">jQuerify</a>. Looking through it, I saw a few potential issues with this script and also decided I wanted something a little more personal, so I came up with my own version:</p>
<p><a href="javascript:(function(){if(!window.jQuery){var s=document.createElement('script');s.src='http://jquery.com/src/jquery-latest.js';document.getElementsByTagName('head')[0].appendChild(s);var z=setInterval(function(){if(window.jQuery){$j=jQuery.noConflict();alert('jQuery loaded!');window.clearInterval(z)}},100)}if(!window.$){window.$=function(x){return document.getElementById(x)}}})();">$jQuerify</a></p>
<p>Notable differences:</p>
<ul>
<li>Moved the jQuery shortcut <code>$</code> to <code>$j</code>. I always do this on any site I work on because I find <code>$</code> is used by so many other libraries and scripts that I want to minimize conflicts. Using <code>$j</code> also for sure tells me I&#8217;m using jQuery.</li>
<li>If <code>$</code> isn&#8217;t being used it becomes a shortcut to <code>document.getElementById</code>. I think it&#8217;s what people naturally expect <code>$</code> to do, and in my daily coding I like using <code>$('id');</code> better than <code>$j('#id')[0];</code> when all I want to do is return an element.
<li>Added an initial check for jQuery to prevent running the script unnecessary.</li>
</ul>
<p>The full source looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>window.<span style="color: #660066;">jQuery</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> s<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        s.<span style="color: #660066;">src</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'http://jquery.com/src/jquery-latest.js'</span><span style="color: #339933;">;</span>
        document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">var</span> z<span style="color: #339933;">=</span>setInterval<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">jQuery</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                $j <span style="color: #339933;">=</span> jQuery.<span style="color: #660066;">noConflict</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'jQuery loaded!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>z<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span><span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>window.$<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	window.$<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><a href="javascript:(function(){if(!window.jQuery){var s=document.createElement('script');s.src='http://jquery.com/src/jquery-latest.js';document.getElementsByTagName('head')[0].appendChild(s);var z=setInterval(function(){if(window.jQuery){$j=jQuery.noConflict();alert('jQuery loaded!');window.clearInterval(z)}},100)}if(!window.$){window.$=function(x){return document.getElementById(x)}}})();">$jQuerify</a> <-- Try me out, drag me to your tool bar.</p>
<h3>Happy endings</h3>
<p>Now I can just hop back over to the <a href="http://services.moxiecode.com/i18n/">TinyMCE Language Pack Download page</a>, run my bookmarklet, type the following in Firebug:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$j<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#examplecontent form:first table tbody tr'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>c<span style="color: #339933;">,</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> country <span style="color: #339933;">=</span> $j<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'td:eq(2) label'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> code<span style="color: #339933;">=</span> $j<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'td:eq(1) a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(?:code=)(..)/</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>c<span style="color: #339933;">,</span>country<span style="color: #339933;">,</span><span style="color: #3366CC;">'='</span><span style="color: #339933;">,</span>code<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And the list is returned:</p>
<pre>
0 Arabic = ar
1 Bokmål, Norwegian; Norwegian Bokmål = nb
2 Bosnian = bs
3 Bulgarian = bg
4 Catalan; Valencian = ca
5 Chamorro = ch
6 Chinese = zh
7 Croatian = hr
8 Czech = cs
9 Danish = da
10 Dutch; Flemish = nl
11 English = en
12 Estonian = et
13 Finnish = fi
14 French = fr
15 German = de
16 Greek, Modern (1453-) = el
17 Hebrew = he
18 Hungarian = hu
19 Interlingua (International Auxiliary Language Association) = ia
20 Italian = it
21 Japanese = ja
22 Korean = ko
23 Latvian = lv
24 Lithuanian = lt
25 Macedonian = mk
26 Malay = ms
27 Northern Sami = se
28 Norwegian Nynorsk; Nynorsk, Norwegian = nn
29 Persian = fa
30 Polish = pl
31 Portuguese = pt
32 Romanian = ro
33 Russian = ru
34 Sardinian = sc
35 Serbian = sr
36 Sichuan Yi = ii
37 Sinhala; Sinhalese = si
38 Slovak = sk
39 Slovenian = sl
40 Spanish; Castilian = es
41 Swedish = sv
42 Tatar = tt
43 Turkish = tr
44 Twi = tw
45 Ukrainian = uk
46 Vietnamese = vi
</pre>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/07/08/inject-jquery-into-any-page-a-better-jquery-bookmarklet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Note to jQuery developer team: Please use curly brackets!</title>
		<link>http://readystate4.com/2008/07/03/note-to-jquery-developer-team-please-use-parentheses/</link>
		<comments>http://readystate4.com/2008/07/03/note-to-jquery-developer-team-please-use-parentheses/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 17:25:37 +0000</pubDate>
		<dc:creator>Mauvis</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://readystate4.com/2008/07/03/note-to-jquery-developer-team-please-use-parentheses/</guid>
		<description><![CDATA[If you haven&#8217;t gathered so far, I think the jQuery JavaScript library is the dog&#8217;s bollocks. Its small, efficient, and has improved my life as a developer almost as much as Firebug. jQuery gets flack occasionally for containing complex or cryptic code full of ternary operators and multiple variable declarations in a single statement (eg. [...]]]></description>
			<content:encoded><![CDATA[<p>If you haven&#8217;t gathered so far, I think the <a href="http://jquery.com/">jQuery</a> JavaScript library is the dog&#8217;s bollocks. Its small, efficient, and has improved my life as a developer almost as much as <a href="http://getfirebug.com/">Firebug</a>. jQuery gets flack occasionally for containing complex or cryptic code full of ternary operators and multiple variable declarations in a single statement (eg. a=b=1), which I mostly see as concise and efficient coding however, there&#8217;s one thing about the jQuery library that I can&#8217;t stand. It&#8217;s something every developer should do and if you&#8217;re not doing it then you&#8217;re a jerk and that, ladies and gentlemen, is omitting your curly brackets.</p>
<p>Look at this code snippet from the jQuery library to see what I mean:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> length<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #006600; font-style: italic;">// Only deal with non-null/undefined values</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>options <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span> i <span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #006600; font-style: italic;">// Extend the base object</span>
		<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066;">name</span> <span style="color: #000066; font-weight: bold;">in</span> options <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> src <span style="color: #339933;">=</span> target<span style="color: #009900;">&#91;</span> <span style="color: #000066;">name</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> copy <span style="color: #339933;">=</span> options<span style="color: #009900;">&#91;</span> <span style="color: #000066;">name</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Prevent never-ending loop</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> target <span style="color: #339933;">===</span> copy <span style="color: #009900;">&#41;</span>
				<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Recurse if we're merging object values</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> deep <span style="color: #339933;">&amp;&amp;</span> copy <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> copy <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;object&quot;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>copy.<span style="color: #660066;">nodeType</span> <span style="color: #009900;">&#41;</span>
				target<span style="color: #009900;">&#91;</span> <span style="color: #000066;">name</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> jQuery.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span> deep<span style="color: #339933;">,</span>
					<span style="color: #006600; font-style: italic;">// Never move original objects, clone them</span>
					src <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span> copy.<span style="color: #660066;">length</span> <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #339933;">?</span> <span style="color: #009900;">&#91;</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span>
				<span style="color: #339933;">,</span> copy <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">// Don't bring in undefined values</span>
			<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> copy <span style="color: #339933;">!==</span> undefined <span style="color: #009900;">&#41;</span>
				target<span style="color: #009900;">&#91;</span> <span style="color: #000066;">name</span> <span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> copy<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Return the modified object</span>
<span style="color: #000066; font-weight: bold;">return</span> target<span style="color: #339933;">;</span></pre></div></div>

<p style="margin-top:10px;">
Coding in this way leads is extremely error-prone especially for open-souce projects where many others are modifying your code. Please stop it.</p>
<p>Love,</p>
<p>A dedicated user</p>
]]></content:encoded>
			<wfw:commentRss>http://readystate4.com/2008/07/03/note-to-jquery-developer-team-please-use-parentheses/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
