<?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>Learning jQuery &#187; Announcement</title>
	<atom:link href="http://www.learningjquery.com/category/jquery/announcement/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learningjquery.com</link>
	<description>Tips, techniques, and tutorials for the jQuery JavaScript library</description>
	<lastBuildDate>Tue, 17 Jan 2012 14:14:01 +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>Introducing jQuery API Search</title>
		<link>http://www.learningjquery.com/2010/09/introducing-jquery-api-search</link>
		<comments>http://www.learningjquery.com/2010/09/introducing-jquery-api-search#comments</comments>
		<pubDate>Fri, 10 Sep 2010 11:28:26 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[jQuery Resources]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/?p=1240</guid>
		<description><![CDATA[Half-baked tutorials and plugins have been stacking up for months in my virtual kitchen, waiting for me to fire up the oven, finish the cooking, and spread them out on the table. For some reason, though, I've become less and less sure about whether I've put all the right ingredients into the mix. It's irritating, [...]]]></description>
			<content:encoded><![CDATA[<p>Half-baked tutorials and plugins have been stacking up for months in my virtual kitchen, waiting for me to fire up the oven, finish the cooking, and spread them out on the table. For some reason, though, I've become less and less sure about whether I've put all the right ingredients into the mix. It's irritating, to be sure, but I'm tired of fretting about it. I'm going to consider this the first of what I hope to be many "taste tests" — experiments in various degrees of completion thrown against the wall to see what, if anything, sticks.</p>
<p>As some of you may know, the online jQuery documentation went through a major overhaul in January of this year, coinciding with the release of jQuery 1.4. Packt Publishing "open sourced" the jQuery 1.4 Reference Guide that Jonathan Chaffer and I had been writing, allowing us to put its entire contents (and more) on <a href="http://api.jquery.com/">api.jquery.com</a>. Some of you may also know that <a href="http://api.jquery.com/api/">the raw XML content of the site is available as a single file</a>, which has allowed other sites such as <a href="http://jqapi.com">jqapi.com</a> and <a href="http://idocs.brandonaaron.net">idocs.brandonaaron.net</a> to provide alternative views of that content. But what most of you probably do <em>not</em> know is that the jQuery API has been available for quite some time as a searchable API that returns the results in JSON format.</p>
<span id="more-1240"></span>
<p><strong>Note:</strong> The <em>reason</em> you probably don't know about it is that it's half-baked. So, please go easy on it until some smart people have a chance to look under the hood at what I'm doing. Crazy abuse will surely bring it to its knees.</p>
<h4>Motivation</h4>
<p>I wanted to let people access the jQuery documentation via JavaScript from any other site and pull out exactly what is needed. I also wanted to play around with JSONP. This fits both of those desires.</p>

<h4>URL</h4>
<p>To access the searchable API, use the following URL:</p>
<p>http://api.jquery.com/jsonp/</p>

<h4>Examples</h4>
<p>You can tap into the API with one of jQuery's Ajax methods. If you use <code>$.get()</code> or <code>$.getJSON()</code>, you'll need to append "?callback=?" to the URL. With <code>$.get()</code>, you'll also need to set the <code>dataType</code> argument to "jsonp". </p>
<p><i>Find entries in the API that have "class" in their name and then do something with them:</i>  </p>
<div class="igBar"><span id="ljavascript-5"><a href="#" onclick="javascript:showPlainTxt('javascript-5'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-5">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><a href="/wp-content/themes/ljq/docs-1.7.php?fn=$.get"><span style="">$.<span style="color: #660066;">get</span></span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://api.jquery.com/jsonp/?callback=?'</span><span style="color: #339933;">,</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#123;</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'class'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=data"><span style="">data</span></a><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// do something with data</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #3366CC;">'jsonp'</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />
<p><i>Find all effects-category entries and then do something with them: </i>  </p>
<div class="igBar"><span id="ljavascript-6"><a href="#" onclick="javascript:showPlainTxt('javascript-6'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-6">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><a href="/wp-content/themes/ljq/docs-1.7.php?fn=$.getJSON"><span style="">$.<span style="color: #660066;">getJSON</span></span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://api.jquery.com/jsonp/?callback=?'</span><span style="color: #339933;">,</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#123;</span>category<span style="color: #339933;">:</span> <span style="color: #3366CC;">'effects'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// do something with json</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />
<p>You can, of course, also use the low-level <code>$.ajax()</code> method.   </p>
<p><i>Find entries with a title that ends in "ajax"; append a link for each to the document body:</i>
</p>      
<div class="igBar"><span id="ljavascript-7"><a href="#" onclick="javascript:showPlainTxt('javascript-7'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-7">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><a href="/wp-content/themes/ljq/docs-1.7.php?fn=$.ajax"><span style="">$.<span style="color: #660066;">ajax</span></span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; url<span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://api.jquery.com/jsonp/'</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; dataType<span style="color: #339933;">:</span> <span style="color: #3366CC;">'jsonp'</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=data"><span style="">data</span></a><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span> <span style="color: #3366CC;">'ajax'</span><span style="color: #339933;">,</span> match<span style="color: #339933;">:</span> <span style="color: #3366CC;">'end'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>json<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #339933;">,</span> len<span style="color: #339933;">=</span>json.<span style="color: #660066;">length</span>; i<span style="color: #339933;">&lt;</span>len ; i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> entry <span style="color: #339933;">=</span> json<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;a /&gt;'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; href<span style="color: #339933;">:</span> entry.<span style="color: #660066;">url</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=html"><span style="">html</span></a><span style="color: #339933;">:</span> entry.<span style="color: #660066;">title</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=appendTo"><span style="">appendTo</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<h4>Search Types</h4>
<p>The JSONP API is searchable by name, category, and version. Searching by more than one criterion returns results that match <em>all</em> of the criteria. <strong>All searches are case-insensitive.</strong></p>

<ul>
  <li><h5>Search by name:</h5>
    <ul>
      
      <li><strong>Key</strong>: title</li>
      <li><strong>Value</strong>: the name of any jQuery method, property, or selector</li>
      <li><strong>Searches in</strong>: post title and post slug</li>
      <li><strong>Substitutions</strong>: Before querying the database, all "$" are converted to "jQuery" and each instance of one or more spaces is converted to a hyphen ("-") for both the search values and the the post title and slug.</li>
      <li><strong>Default</strong>: all titles</li>
    </ul>
  </li>
  
  <li><h5>Search by category name</h5>
    <ul>
      <li><strong>Key</strong>: category</li>
      <li><strong>Value</strong>: category name</li>
      <li><strong>Substitutions</strong>: Before querying the database, each instance of one or more spaces is converted to a hyphen ("-")</li>
      <li><strong>Searches in</strong>: category slug</li>
      <li><strong>Default</strong>: all categories</li>
    </ul>
  </li>
  <li>
  <h5>Search by version number</h5>
    <ul>
    
      <li><strong>Key</strong>: version</li>
      <li><strong>Value</strong>: a jQuery version number</li>
      <li><strong>Searches in</strong>: category slug for all categories that are a child of the main "version" category</li>
      <li><strong>Default</strong>: all versions</li>
    </ul>
    
  </li>
</ul>
<h4>String Matching</h4>
  <p>The "match" parameter lets you be confine the results to those that match the entire search term, or just the start or end of it.  </p>
<ul>
  <li><strong>Key</strong>: match</li>
  <li><strong>Value</strong>: one of "start", "end", or "exact" (for search by version number, one of "end" or "exact")</li>
  <li><strong>Default</strong>: "anywhere", except for version number, which has a default of "start"</li>
</ul>

<h4>Returned Data</h4>
<p>Data is returned as an array of objects. Each item in the array is an object representing a single method, property, or selector. For example, a result with one item would have the following structure:</p>

<div class="igBar"><span id="ljavascript-8"><a href="#" onclick="javascript:showPlainTxt('javascript-8'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-8">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#91;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #3366CC;">&quot;url&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// &quot;method&quot;, &quot;property&quot;, or &quot;selector&quot;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #3366CC;">&quot;signatures&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;added&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;params&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;type&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;optional&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// either &quot;true&quot; or an empty string</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;desc&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span> <span style="color: #006600; font-style: italic;">// description of the parameter</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#93;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #3366CC;">&quot;desc&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// short description</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #3366CC;">&quot;longdesc&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">// long description</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #3366CC;">&quot;return&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;...&quot;</span> <span style="color: #006600; font-style: italic;">// type of return value</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#93;</span></div></li>
</ol></div>
</div></div><br />
<p>Note that currently the examples/demos from each entry are not returned.</p>
<h4>A (Fairly) Basic Demo</h4>
<p>I put together a quick demo to give an idea of the API's flexibility. Type something into the "Name" field in the form below—say, "ajax"—and watch as the results come back. Inside the "Advanced" area, choose the "Matching... <strong>End</strong>" radio button and search again to see how the results differ.  </p>
<div class="jqas">
  <form id="jqas" action="" class="group">
    <div>
      <a id="search-again" class="js-hide btn" href="#">&#x271A; Search Again</a>
      <h3>jQuery API Search <span class="note">A demonstration</span></h3>
    </div>
    <fieldset>
      <div class="text">
        <label for="title">Name</label>
        <input type="text" id="title" name="title" />
      </div>
      <div class="text">
        <label for="category">Category</label>
        <input type="text" id="category" name="category" />
      </div>
      <div class="text">
        <label for="version">Version</label>
        <input type="text" id="version" name="version" />
      </div>
      <div class="actions">
        <button type="submit">Search</button>
      </div>
    </fieldset>
    <fieldset class="includes">
      <h4><a id="toggle-advanced" class="btn" href="#advanced"><span>&#x2712;</span> Advanced</a></h4>
      <div id="advanced" class="js-hide">
        <h5>Matching</h5>
        <div class="radio">
          <input type="radio" checked="checked" value="" id="match_anywhere" name="match" />
          <label for="match_anywhere">Anywhere</label>
        </div>
        <div class="radio">
          <input type="radio" value="start" id="match_start" name="match" />
          <label for="match_start">Start</label>
        </div>
        <div class="radio">
          <input type="radio" value="end" id="match_end" name="match" />
          <label for="match_end">End</label>
        </div>
        <div class="radio">
          <input type="radio" value="exact" id="match_exact" name="match" />
          <label for="match_exact">Exact</label>
        </div>
        <h5>Include in Results</h5>
        <div class="checkbox">
          <input type="checkbox" checked="checked" value="added" id="added" name="include[]" />
          <label for="added">Version Added</label>
        </div>
        <div class="checkbox">
          <input type="checkbox" checked="checked" value="params" id="params" name="include[]" />
          <label for="params">Arguments</label>
        </div>
      
        <div class="checkbox">
          <input type="checkbox" checked="checked" value="desc" id="short_description" name="include[]" />
          <label for="short_description">Short Description</label>
        </div>
        <div class="checkbox">
          <input type="checkbox" checked="checked" value="longdesc" id="long_description" name="include[]" />
          <label for="long_description">Long Description</label>
        </div>
      </div>
    </fieldset>
  </form>
<p><a id="clear-results" href="#">Clear Results</a></p>
<div id="log"></div>
</div>
<h4>A Little Less Basic Demo</h4>
<p>I replicated this search form on a test server and added back-button support with <a href="http://benalman.com/projects/jquery-bbq-plugin/">Ben Alman's crazy delicious BBQ Plugin</a>. Try out <a href="http://test.learningjquery.com/jqas/">the demo</a>.</p>
<h4>But wait! There's more!</h4>
<p>I put the whole shebang (well, except for the server-side stuff) in a GitHub repo. <a href="http://github.com/kswedberg/jQuery-API-Search">Clone it, fork it, have your way with it</a>.</p>

<h4>But Wait! There's Less!</h4>
<p>As I mentioned above, this little project is incomplete. If you peek at the scripts, you'll quickly spot some major chunks of code in need of refactoring. Also, had I but world enough and time, I'd use a nice templating system such as <a href="http://github.com/janl/mustache.js">mustache.js</a> or the <a href="http://github.com/nje/jquery-tmpl">jQuery Templates plugin</a> to output the search results. But I'll leave all that for another day (or another developer).  </p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2010/09/introducing-jquery-api-search/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Spring 2010 jQuery Conference: San Francisco Bay Area</title>
		<link>http://www.learningjquery.com/2010/03/spring-2010-jquery-conference-san-francisco-bay-area</link>
		<comments>http://www.learningjquery.com/2010/03/spring-2010-jquery-conference-san-francisco-bay-area#comments</comments>
		<pubDate>Mon, 29 Mar 2010 13:26:17 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Bay Area]]></category>
		<category><![CDATA[California]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[San Francisco]]></category>
		<category><![CDATA[West Coast]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/?p=1057</guid>
		<description><![CDATA[Since the fall of 2007, jQuery developers around the world have been making an annual pilgrimage to Boston, Massachusetts, to meet jQuery team members, JavaScript luminaries, and other jQuery developers at the official jQuery Conference. This spring, in response to growing demand, the jQuery Project is offering its first-ever official jQuery conference on the U.S [...]]]></description>
			<content:encoded><![CDATA[<p>Since the fall of 2007, jQuery developers around the world have been making an annual pilgrimage to Boston, Massachusetts, to meet jQuery team members, JavaScript luminaries, and other jQuery developers at the official jQuery Conference. This spring, in response to growing demand, the jQuery Project is offering its first-ever <a href="http://events.jquery.org/2010/sf-bay-area/">official jQuery conference on the U.S west coast</a>. The conference will take place April 24&ndash;25 in Mountain View, California, and will include <a href="http://events.jquery.org/2010/sf-bay-area/speakers/">top-notch presentations</a> from the jQuery team, as well as other web development and performance experts. Additionally, the conference will be preceded by a one-day intensive jQuery training course in downtown San Francisco, led by <a href="http://appendto.com/">appendTo</a> a leading jQuery training and consulting company.</p>
<span id="more-1057"></span>
<p>Priced at $199, the two-day conference is one of the best bargains you'll find anywhere for a full-on tech conference. The jQuery team is committed to keeping the price as low as possible, relying on the <a href="http://jquery.org/sponsors">support</a> of <a href="http://events.jquery.org/2010/sf-bay-area/sponsors/">sponsors</a> to help defray the cost of registration. jQuery developers from beginner to advanced will learn a ton, have a great time, and meet many others who are using jQuery in innovative ways to make the web a better place.</p>
<p>On a personal note, this will be the first jQuery conference ever that I won't be able to attend (regrettably, a scheduling conflict is keeping me home this time). But having heard many of the speakers in the past and having been involved a bit in the planning of this conference, I can assure you that <em>you</em> won't want to miss it. While we hope to continue offering a west-coast event on an annual basis, as we have done with the east-coast event a lot will depend on the level of interest and attendance this time around. So, what are you waiting for? <a href="http://events.jquery.org/2010/sf-bay-area/register/">Sign up now</a>!</p>
<p>One brief personal plug: I will be teaching a <a href="http://ideafoundry.info/jquery">3-day jQuery class</a> June 2&ndash;4 in beautiful Holland, Michigan. If for some reason you can't make it to the conference in April&mdash;or even if you can&mdash;you might want to consider taking the class. This will be the fourth class I've taught with <a href="http://ideafoundry.info/">Idea Foundry</a>, and if it's anything like the others, we'll have a blast, with lots and lots of great learning.</p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2010/03/spring-2010-jquery-conference-san-francisco-bay-area/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Better, Stronger, Safer jQuerify Bookmarklet</title>
		<link>http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet</link>
		<comments>http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet#comments</comments>
		<pubDate>Wed, 29 Apr 2009 14:12:43 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[DOM Traversing]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[bookmarklets]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/?p=687</guid>
		<description><![CDATA[A long time ago I built myself a little bookmarklet to load jQuery on pages that don't already have it. The idea was to allow me to play around with any page on the web, using jQuery in the Firebug (and now Safari or IE8) console. I blogged about it, got lots of great feedback, [...]]]></description>
			<content:encoded><![CDATA[<p>A long time ago I built myself a little bookmarklet to load jQuery on pages that don't already have it. The idea was to allow me to play around with any page on the web, using jQuery in the Firebug (and now Safari or IE8) console. I <a href="http://www.learningjquery.com/2006/12/jquerify-bookmarklet">blogged about it</a>, got lots of great feedback, and then <a href="http://www.learningjquery.com/2008/06/updated-jquery-bookmarklet">blogged about an improved version</a>. Now that a lot more great feedback has come through the comments of the updated bookmarklet post, I've decided to update it one more time.</p>
<span id="more-687"></span>
<h4>The Bookmarklet</h4>
<p>To use the bookmarklet, drag the following link to your bookmark/favorites list:</p>
<p> 
&raquo; <a href="javascript:(function(){var%20el=document.createElement('div'),b=document.getElementsByTagName('body')[0];otherlib=false,msg='';el.style.position='fixed';el.style.height='32px';el.style.width='220px';el.style.marginLeft='-110px';el.style.top='0';el.style.left='50%';el.style.padding='5px%2010px';el.style.zIndex=1001;el.style.fontSize='12px';el.style.color='#222';el.style.backgroundColor='#f99';if(typeof%20jQuery!='undefined'){msg='This%20page%20already%20using%20jQuery%20v'+jQuery.fn.jquery;return%20showMsg();}else%20if(typeof%20$=='function'){otherlib=true;}%20function%20getScript(url,success){var%20script=document.createElement('script');script.src=url;var%20head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done&#038;&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;success();script.onload=script.onreadystatechange=null;head.removeChild(script);}};head.appendChild(script);}%20getScript('http://code.jquery.com/jquery-latest.min.js',function(){if(typeof%20jQuery=='undefined'){msg='Sorry,%20but%20jQuery%20wasn\'t%20able%20to%20load';}else{msg='This%20page%20is%20now%20jQuerified%20with%20v'+jQuery.fn.jquery;if(otherlib){msg+='%20and%20noConflict().%20Use%20$jq(),%20not%20$().';}}%20return%20showMsg();});function%20showMsg(){el.innerHTML=msg;b.appendChild(el);window.setTimeout(function(){if(typeof%20jQuery=='undefined'){b.removeChild(el);}else{jQuery(el).fadeOut('slow',function(){jQuery(this).remove();});if(otherlib){$jq=jQuery.noConflict();}}},2500);}})();">jQuerify</a> &laquo;
</p>
<p>Then, when you're on a page in which you want to play around with jQuery in the console, just click the bookmarklet.</p>

<h4>Problems with the Other One</h4>
<p>The biggest problem with the former version was that it didn't work when other libraries that use the <code>$</code> function, such as Prototype and Mootools, were already loaded on the page. A number of people in the comments suggested that I simply add a <code>jQuery.noConflict();</code> line to the script. But I wasn't crazy about the idea of having to use <code>jQuery()</code> instead of <code>$()</code> even if no other libraries had been loaded. </p>

<p>Another problem, one that I noticed while testing my new version, was that sometimes the jQuery file that I was inserting from the Google CDN wouldn't fully load by the time I attempted to use it later in the bookmarklet. At least, I think that's what was going on. In any case, it was throwing a "jQuery is not defined" error.</p>

<h4>A Few Improvements in This One</h4>
<p>To handle the problems, I'm having the script do a few things differently:</p>
<ul>
  <li>Set up a counter to check 10 times if jQuery is loaded before giving up. </li>
  <li>Use a setTimeout to put a one-quarter-second (250ms) delay interval in between attempts.</li>
  <li>Check if the <code>$()</code> function is already being used by another library. If it is:
    <ul>
      <li>use jQuery's $.noConflict function to release the <code>$()</code> to the other library. </li>
      <li>set <code>$jq</code> as an alias to <code>jQuery</code> for convenience.</li>
      <li>mention in the flash notice that jQuery is in noConflict mode and that <code>$jq()</code> should be used instead of <code>$()</code>.</li>
    </ul>
  </li>
  <li>If after multiple attempts jQuery still won't load for some reason, set the flash notice's message accordingly and then remove it through plain old JavaScript rather than jQuery.</li>
</ul>

<div id="update1" class="update">
<h4>Update</h4>
<p>Based on a few comments, I've updated the script one more time to "basically watch the onload and readyState, and fire the callback, thus removing the necessity to poll," as <a href="#comment-72913">Paul Irish describes below</a>.</p>
<p>The script also removes references to <code>script</code> after success now, <a href="#comment-80161">as suggested below</a>, to avoid a memory leak.</p>
<p>Here is the updated link (I also updated it above):</p>
<p>&raquo; <a href="javascript:(function(){var%20el=document.createElement('div'),b=document.getElementsByTagName('body')[0];otherlib=false,msg='';el.style.position='fixed';el.style.height='32px';el.style.width='220px';el.style.marginLeft='-110px';el.style.top='0';el.style.left='50%';el.style.padding='5px%2010px';el.style.zIndex=1001;el.style.fontSize='12px';el.style.color='#222';el.style.backgroundColor='#f99';if(typeof%20jQuery!='undefined'){msg='This%20page%20already%20using%20jQuery%20v'+jQuery.fn.jquery;return%20showMsg();}else%20if(typeof%20$=='function'){otherlib=true;}%20function%20getScript(url,success){var%20script=document.createElement('script');script.src=url;var%20head=document.getElementsByTagName('head')[0],done=false;script.onload=script.onreadystatechange=function(){if(!done&#038;&(!this.readyState||this.readyState=='loaded'||this.readyState=='complete')){done=true;success();script.onload=script.onreadystatechange=null;head.removeChild(script);}};head.appendChild(script);}%20getScript('http://code.jquery.com/jquery-latest.min.js',function(){if(typeof%20jQuery=='undefined'){msg='Sorry,%20but%20jQuery%20wasn\'t%20able%20to%20load';}else{msg='This%20page%20is%20now%20jQuerified%20with%20v'+jQuery.fn.jquery;if(otherlib){msg+='%20and%20noConflict().%20Use%20$jq(),%20not%20$().';}}%20return%20showMsg();});function%20showMsg(){el.innerHTML=msg;b.appendChild(el);window.setTimeout(function(){if(typeof%20jQuery=='undefined'){b.removeChild(el);}else{jQuery(el).fadeOut('slow',function(){jQuery(this).remove();});if(otherlib){$jq=jQuery.noConflict();}}},2500);}})();">jQuerify</a> &laquo;</p>
<p>And here is the updated script:</p>
</div>
<div id="bookmarklet-src">
<div class="igBar"><span id="ljavascript-10"><a href="#" onclick="javascript:showPlainTxt('javascript-10'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-10">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> el<span style="color: #339933;">=</span>document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; b<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; otherlib<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; msg<span style="color: #339933;">=</span><span style="color: #3366CC;">''</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=position"><span style="">position</span></a><span style="color: #339933;">=</span><span style="color: #3366CC;">'fixed'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=height"><span style="">height</span></a><span style="color: #339933;">=</span><span style="color: #3366CC;">'32px'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=width"><span style="">width</span></a><span style="color: #339933;">=</span><span style="color: #3366CC;">'220px'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<span style="color: #660066;">marginLeft</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'-110px'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<span style="color: #660066;">top</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'0'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<span style="color: #660066;">left</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'50%'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<span style="color: #660066;">padding</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'5px 10px'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<span style="color: #660066;">zIndex</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;color:#800000;">1001</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<span style="color: #660066;">fontSize</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'12px'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<span style="color: #660066;">color</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'#222'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; el.<span style="color: #660066;">style</span>.<span style="color: #660066;">backgroundColor</span><span style="color: #339933;">=</span><span style="color: #3366CC;">'#f99'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> jQuery<span style="color: #339933;">!=</span><span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; msg<span style="color: #339933;">=</span><span style="color: #3366CC;">'This page already using jQuery v'</span><span style="color: #339933;">+</span>jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">jquery</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> showMsg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</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><span style="color: #000066; font-weight: bold;">typeof</span> $<span style="color: #339933;">==</span><span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; otherlib<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #006600; font-style: italic;">// more or less stolen form jquery core and adapted by paul irish</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">function</span> getScript<span style="color: #009900;">&#40;</span>url<span style="color: #339933;">,</span>success<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> script<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>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; script.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>url;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> head<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;color:#800000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=done"><span style="">done</span></a><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Attach handlers for all browsers</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; script.<span style="color: #000066;">onload</span><span style="color: #339933;">=</span>script.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=done"><span style="">done</span></a> &#038;& <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">readyState</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'loaded'</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">readyState</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'complete'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=done"><span style="">done</span></a><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; success<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; script.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> script.<span style="color: #660066;">onreadystatechange</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; head.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>script<span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; head.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>script<span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; getScript<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'http://code.jquery.com/jquery-latest.min.js'</span><span style="color: #339933;">,</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> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> jQuery<span style="color: #339933;">==</span><span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; msg<span style="color: #339933;">=</span><span style="color: #3366CC;">'Sorry, but jQuery wasn<span style="color: #000099; font-weight: bold;">\'</span>t able to load'</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; msg<span style="color: #339933;">=</span><span style="color: #3366CC;">'This page is now jQuerified with v'</span> <span style="color: #339933;">+</span> jQuery.<span style="color: #660066;">fn</span>.<span style="color: #660066;">jquery</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>otherlib<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>msg<span style="color: #339933;">+=</span><span style="color: #3366CC;">' and noConflict(). Use $jq(), not $().'</span>;<span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> showMsg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">function</span> showMsg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; el.<span style="color: #660066;">innerHTML</span><span style="color: #339933;">=</span>msg;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; b.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; window.<span style="color: #660066;">setTimeout</span><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> jQuery<span style="color: #339933;">==</span><span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; b.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; jQuery<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=fadeOut"><span style="">fadeOut</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slow'</span><span style="color: #339933;">,</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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; jQuery<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=remove"><span style="">remove</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>otherlib<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $jq<span style="color: #339933;">=</span>jQuery.<span style="color: #660066;">noConflict</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #339933;">,</span><span style="color: #CC0000;color:#800000;">2500</span><span style="color: #009900;">&#41;</span>; &nbsp; &nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />
</div>
<p>Let me know if this one causes any problems.</p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet/feed</wfw:commentRss>
		<slash:comments>86</slash:comments>
		</item>
		<item>
		<title>The Year of jQuery UI</title>
		<link>http://www.learningjquery.com/2009/01/the-year-of-jquery-ui</link>
		<comments>http://www.learningjquery.com/2009/01/the-year-of-jquery-ui#comments</comments>
		<pubDate>Sat, 03 Jan 2009 18:44:56 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[DOM Traversing]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/?p=223</guid>
		<description><![CDATA[Two years ago I made the somewhat immodest claim that 2007 would be the "Year of jQuery." Since then, jQuery's popularity has grown in ways that none of the core contributors could have imagined. Now I'm ready to make another bold pronouncement: 2009 will be the year of jQuery UI. Here's why: jQuery UI 1.6 [...]]]></description>
			<content:encoded><![CDATA[Two years ago I made the somewhat immodest claim that 2007 would be the "<a href="http://www.learningjquery.com/2007/01/the-year-of-jquery">Year of jQuery</a>." Since then, <a href="http://jquery.com">jQuery</a>'s <a href="http://www.google.com/trends?q=jquery">popularity</a> has grown in <a href="http://docs.jquery.com/Sites_Using_jQuery">ways</a> that none of the <a href="http://docs.jquery.com/Contributors">core contributors</a> could have imagined. Now I'm ready to make another bold pronouncement: 2009 will be the year of <a href="http://ui.jquery.com/">jQuery UI</a>. Here's why: <span id="more-223"></span>
<ul>
	<li><strong>jQuery UI 1.6 is shaping up to be a rock-solid re-factoring of the entire library.</strong> With <a href="http://blog.jquery.com/2008/12/31/jquery-ui-16rc3-its-getting-really-close/">RC4 released just two days ago</a>, the UI team have further cleaned up the API while providing a set of tools that are even more extensible and configurable than they were before.</li>
	<li><strong>Better project management and greater transparency</strong>. Over the last year or so, Paul Bakaus has done much more than lead the development of jQuery UI. He has shaped and nurtured a <a href="http://ui.jquery.com/about">team of top-notch JavaScript developers</a> and has opened up <a href="http://jqueryui.pbwiki.com/">a lot of the decision-making process</a> to outside scrutiny. This bodes well for the direction of the project.</li>
	<li><strong>Improved jQuery UI ThemeRoller</strong>. <a href="http://ui.jquery.com/ThemeRoller">ThemeRoller</a>, developed and designed by the folks at <a href="http://www.filamentgroup.com/">Filament Group</a>, was already an amazingly useful and elegant complement to jQuery UI. But now it's even better, with a much-improved CSS framework and lighter CSS footprint, a slick default theme, a cool icon sprite set, and more configuration options. Also, it'll soon be easier than ever to <a href="http://jqueryui.pbwiki.com/jQuery-UI-CSS-Framework">create your own UI widgets</a> that take advantage of the ThemeRoller &mdash; with upcoming tools, documentation, and tutorials for making your site "ThemeRoller-ready." </li>
	<li><strong>Improved documentation and demos</strong>. The <a href="http://docs.jquery.com/UI">documentation wiki</a> has undergone some significant updates in recent months, and the <a href="http://ui.jquery.com/demos">demos</a> went through a complete overhaul in coordination with the 1.6rc4 release.</li>
  <li><strong>More widespread adoption</strong>. As the API changes settle down and the core UI developers have more time to spend on providing more widgets and components, such as a spinner, menu, and colorpicker, more sites are sure to join the likes of WordPress in adopting jQuery UI.  </li>
	<li><strong>A new blog</strong>. While most of the details are still under wraps, a brand new weblog dedicated to learning jQuery UI, similar in quality and scope to <a href="http://www.learningjquery.com/">Learning jQuery</a>, will be online soon. </li>
</ul>
I have had the great pleasure to use jQuery UI on a couple recent projects, and I can honestly say that it has come a long way since its first release a year and a half ago. If you haven't used the UI library before, now is a great time to start. If my prediction comes true, you'll be at <a href="http://www.google.com/trends?q=jquery+ui&amp;ctab=0&amp;geo=all&amp;date=all&amp;sort=0">the forefront of a major trend</a>.

<h4><ins datetime="2009-01-03T21:33:43+00:00">Update:</ins></h4>
I failed to mention that the new blog will be run by jQuery UI developer <a href="http://rdworth.org/">Richard D. Worth</a>. In addition to being a great developer, Richard does an awesome job of promoting and explaining jQuery UI. I'm really looking forward to seeing the good stuff he'll be posting soon.]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2009/01/the-year-of-jquery-ui/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>jQuery Site Redesign &#8211; The Community Speaks</title>
		<link>http://www.learningjquery.com/2008/08/jquery-site-redesign-the-community-speaks</link>
		<comments>http://www.learningjquery.com/2008/08/jquery-site-redesign-the-community-speaks#comments</comments>
		<pubDate>Fri, 29 Aug 2008 14:52:38 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[redesign]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/2008/08/jquery-site-redesign-the-community-speaks</guid>
		<description><![CDATA[Re-posted from Rey Bango's blog. As many of you have seen by now, the jQuery Project's site has been redesigned. It had been a long overdue task and it was important to put a fresh new spin on the main hub, and the face, of jQuery. One of the things about the jQuery Project is [...]]]></description>
			<content:encoded><![CDATA[<p><em>Re-posted from <a href="http://www.reybango.com/">Rey Bango's blog</a>.</em></p>

<p>As many of you have seen by now, the <a href="http://jquery.com/">jQuery Project's site</a> <a href="http://jquery.com/blog/2008/08/29/jquerycom-site-redesign/">has been redesigned</a>. It had been a long overdue task and it was important to put a fresh new spin on the main hub, and the face, of jQuery. One of the things about the jQuery Project is that we've never run with the crowd or accepted the norm. By pushing boundaries and sometimes being "in your face," we've not only grown tremendously in popularity but we've pushed most of the other JS library projects to rethink their own principles and make changes to improve their products. That's a good thing for everyone as competition is always good.</p>
<span id="more-104"></span>

<p>So, it should come as no surprise by the drastic change in the jQuery website. So far, the single biggest complaint has been associated with the new banner (ie: rockstar caricature &#038; slogan). Again, we wanted to push the boundaries and come up with something that would generate a lot of buzz. Overall, we've succeeded in that goal with plenty of positive feedback, but unfortunately, with some very negative comments as well. We actually value both types of feedback and want more as it's the only way to determine if we're on the right track. As with any site redesign, you can't please everyone and we understand that. But we also want everyone to realize that this is a first cut and it doesn't mean that it can't be tweaked.</p>

<p>We're actively reviewing all of the feedback and will certainly be looking at how to best handle some of the concerns of the community. After all, the community is what makes the jQuery Project so special and so different from other projects. In addition, the jQuery team has always listened to the needs of the community and this time is no exception. Again, I think the team is unique in that we *DO LISTEN* to the community and we're going to work on making the site an invaluable tool for everyone. So just give us some time to go through the messages and keep an eye on this blog for updates.</p>

<p>Thanks for your patience and we truly appreciate your feedback.</p>

<p>&mdash; Rey Bango</p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2008/08/jquery-site-redesign-the-community-speaks/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>jQuery Documentation Alternatives</title>
		<link>http://www.learningjquery.com/2008/07/jquery-documentation-alternatives</link>
		<comments>http://www.learningjquery.com/2008/07/jquery-documentation-alternatives#comments</comments>
		<pubDate>Tue, 29 Jul 2008 21:55:30 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery.com]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/2008/07/jquery-documentation-alternatives</guid>
		<description><![CDATA[As many of you have discovered by now, jquery.com and its subdomains have been offline intermittently over the past several weeks. On behalf of the jQuery Project Team, I apologize for any inconvenience this has caused. John Resig is aware of the problem and is working with the hosting company to get things resolved as [...]]]></description>
			<content:encoded><![CDATA[As many of you have discovered by now, <a href="http://jquery.com/">jquery.com</a> and its subdomains have been offline intermittently over the past several weeks. On behalf of the jQuery Project Team, I apologize for any inconvenience this has caused.

John Resig is aware of the problem and is working with the hosting company to get things resolved as quickly as possible. In the meantime, Remy Sharp, who runs <a href="http://www.jqueryfordesigners.com/">jQuery for Designers</a>, has graciously provided a few alternatives for API documentation:
<ul>
	<li><a href="http://api.jquery.com/">API Browser</a> (now hosted on api.jquery.com)</li>
	<li><a href="http://remysharp.com/visual-jquery/">Visual jQuery</a></li>
	<li><a href="http://remysharp.com/downloads/jquery-api-browser.air.zip">Adobe Air App</a> (zip) for offline browsing</li>
</ul>

He also has the <a href="http://jquery-api-browser.googlecode.com/svn/trunk/api-docs.xml">raw XML file of the jQuery documentation</a> in an SVN repository hosted at googlecode.com.

Jörn Zaefferer also has a <a href="http://jquery.bassistance.de/api-browser-1.2/">jQuery API Browser</a> that lets you browse by category as well as alphabetically. Also, it can be <a href="http://jquery.bassistance.de/api-browser-1.2/jquery-api-browser.zip">downloaded as a zip file</a>. 

Many thanks to Remy and Jörn for these great resources.]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2008/07/jquery-documentation-alternatives/feed</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Introduction to jQuery UI</title>
		<link>http://www.learningjquery.com/2008/07/introduction-to-jquery-ui</link>
		<comments>http://www.learningjquery.com/2008/07/introduction-to-jquery-ui#comments</comments>
		<pubDate>Wed, 02 Jul 2008 17:35:38 +0000</pubDate>
		<dc:creator>Marc Grabanski</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/2008/07/introduction-to-jquery-ui</guid>
		<description><![CDATA[After many months of stellar work, the jQuery UI team has released version 1.5 of their flagship suite of user-interface widgets, components, and effects. This release was focused on bringing you a standardized development API across all of the components, allowing for a more seamless experience when working with the jQuery UI library. A very [...]]]></description>
			<content:encoded><![CDATA[<p>After many months of stellar work, the jQuery UI team has <a href="http://jquery.com/blog/2008/06/09/jquery-ui-v15-released-focus-on-consistent-api-and-effects/">released version 1.5</a> of their flagship suite of user-interface widgets, components, and effects. This release was focused on bringing you a standardized development API across all of the components, allowing for a more seamless experience when working with the jQuery UI library. </p><span id="more-99"></span>

<p>A very exciting CSS theming application was also released with jQuery UI 1.5, called <a href="http://ui.jquery.com/themeroller">ThemeRoller</a>. ThemeRoller is an amazing way to customize the style and colors across all of the jQuery UI components. It comes with a few preset styles, as well as allowing you to create your own. Once you are done, it packages your theme into a zip file that contains all of the images and CSS you need.</p>

<h4>Brief Overview of the jQuery UI Project</h4>
<p>The jQuery UI project was originally created to bring you a set of "official" jQuery plugins. Mature components from the plugins repository were pulled together to form the first release of jQuery UI. But since each of these plugins had its own style, having been written by different authors, the first release of the library felt a bit cumbersome when packaged together. With that in mind, the focus of UI 1.5 was on achieving a coherent, standardized API to eliminate much of the differences between the components. Through much time and effort, many bugs and feature requests were addressed along the way as well.</p>
<h4>Inside Look at jQuery UI Version 1.5</h4>
<p>Before starting, I want to make sure you know where the <a href="http://docs.jquery.com/UI">jQuery UI Documentation</a> is located. You may also want to head to the <a href="http://ui.jquery.com/download">download page</a> to grab the library for yourself. Note that the development bundle is the easiest to get started with.</p>
<p>
First, let's start by including the necessary files for jQuery UI: jQuery latest js file, the Flora theme complete stylesheet, and the core UI file. Each of the components is built on top of these files. Here is how to include them:</p>

<div class="igBar"><span id="lhtml-17"><a href="#" onclick="javascript:showPlainTxt('html-17'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">HTML:</span><br /><div id="html-17">
<div class="html" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;themes/flora/flora.all.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Flora (Default)&quot;</span> <span style="color: #66cc66;">/</span><span style="color: #000000;">&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://code.jquery.com/jquery-latest.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ui/ui.core.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
</ol></div>
</div></div><br />

<p>You may want to download these files and put them on your own server, but this is just fine for our demonstration.</p>

<p>At this point you may include the jquery.ui.all.js script for testing, or include each of the components individually. Here are the components that we are using for this demo:</p>

<div class="igBar"><span id="lhtml-18"><a href="#" onclick="javascript:showPlainTxt('html-18'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">HTML:</span><br /><div id="html-18">
<div class="html" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ui/ui.draggable.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ui/ui.resizable.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ui/ui.accordion.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
</ol></div>
</div></div><br />

<h4>Activating Components</h4>
<p>Each component has a constructor method, which is the component name. For instance, we can make a div draggable by using the <code>draggable()</code> method:</p>

<div class="igBar"><span id="ljavascript-19"><a href="#" onclick="javascript:showPlainTxt('javascript-19'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-19">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#dragme&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<div id="dragme" class="draggable"></div>
<p>The component defaults can be overridden by passing in options to the main function. For instance, if we want to make the div drag only horizontally, we can set the axis option to "x" with the following code:</p>

<div class="igBar"><span id="ljavascript-20"><a href="#" onclick="javascript:showPlainTxt('javascript-20'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-20">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#dragme-x&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> axis<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;x&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<div id="dragme-x" class="draggable"></div>

<p>Likewise, the Accordion can be accessed the same way. Here we set a custom option to specify the accordion to slide on the mouseover event:</p>

<div class="igBar"><span id="ljavascript-21"><a href="#" onclick="javascript:showPlainTxt('javascript-21'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-21">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#accordionDemo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">accordion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> event<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;mouseover&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />


<ul id="accordionDemo" class="ui-accordion-container" style="width: 400px;"><li><a href='#'>Test 1</a><div>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div></li><li><a href='#'>Test 2</a><div>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam <br /></div></li><li><a href='#'>Test 3</a><div>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </div></li></ul>
<div style="border-top: 1px solid grey"></div>

<p>Some of the components, such as draggable and resizable, can even be combined:</p>

<div class="igBar"><span id="ljavascript-22"><a href="#" onclick="javascript:showPlainTxt('javascript-22'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-22">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#dragme-resize&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">resizable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<div id="dragme-resize" class="draggable" style="border:2px solid grey;background:#CDE7B0"></div>

<p>This first makes the div draggable, then adds the resize handles to the div.</p>

<p>Now you should have what you need to start with each of the components! Head to the <a href="http://ui.jquery.com/functional_demos/">functional demos page</a> to see in-depth examples of each of the components.</p>

<h4>Looking at the Future of jQuery UI</h4>
<p>With Paul Bakaus <a href="http://jquery.com/blog/2008/01/23/jquery-ui-and-beyond-the-jquery-liferay-partnership/">hired as (paid) full-time lead of jQuery UI</a>, the project has been energized, charging forward by leaps and bounds. With an <a href="http://docs.jquery.com/UI/Roadmap">ever-growing set of UI components</a>, jQuery UI's future is shaping up to be one of great promise.</p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2008/07/introduction-to-jquery-ui/feed</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Tutorials Elsewhere</title>
		<link>http://www.learningjquery.com/2007/11/tutorials-elsewhere</link>
		<comments>http://www.learningjquery.com/2007/11/tutorials-elsewhere#comments</comments>
		<pubDate>Fri, 02 Nov 2007 20:27:24 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[jQuery Resources]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/2007/11/tutorials-elsewhere</guid>
		<description><![CDATA[Quite a few jQuery tutorials have been posted around the web recently. It's always great to see more people not only learning jQuery, but also teaching it to others. Here are just a few that I think could be helpful to readers of Learning jQuery: jQuery Crash Course. Nathan Smith shows he scripted an airplane [...]]]></description>
			<content:encoded><![CDATA[Quite a few jQuery tutorials have been posted around the web recently. It's always great to see more people not only learning jQuery, but also teaching it to others. Here are just a few that I think could be helpful to readers of Learning jQuery:
<span id="more-81"></span>
<ul>
	<li><a href="http://www.digital-web.com/articles/jquery_crash_course">jQuery Crash Course</a>. Nathan Smith shows he scripted an airplane seat picker script with jQuery. Beautifully designed with nice, clean code.</li>
	<li><a href="http://blog.pengoworks.com/blogger/index.cfm?action=blog:611">Understanding the "Chain"</a>. Dan G. Switzer discusses how he went from an incorrect assumption to a solid understanding.</li>

	<li><a href="http://remysharp.com/2007/10/08/what-is-jsonp/">What is JSONP?</a>. Remy Sharp describes the JSONP method of script-tag injection and shows how it can be done with jQuery.</li>
	<li><a href="http://www.bennadel.com/blog/1009-jQuery-Demo-Creating-A-Sliding-Image-Puzzle-Plug-In.htm">Creating A Sliding Image Puzzle Plug-In</a>. Ben Nadel demonstrates how he built a really cool sliding-image puzzle.</li>
	
</ul>
Any others out there that you have found particularly useful? Let us know in the comments.]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2007/11/tutorials-elsewhere/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Thanks for jQuery</title>
		<link>http://www.learningjquery.com/2007/10/thanks-for-jquery</link>
		<comments>http://www.learningjquery.com/2007/10/thanks-for-jquery#comments</comments>
		<pubDate>Thu, 01 Nov 2007 03:35:27 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[jQuery Resources]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/2007/10/thanks-for-jquery</guid>
		<description><![CDATA[Last week I attended The Ajax Experience conference in Boston (no, I didn't go to a Red Sox game), sponsored by the folks at ajaxian.com The schedule was packed with outstanding presentations. But the highlight of my trip was jQueryCamp07, which was held at Harvard University on Saturday. Throughout the week I had quite a [...]]]></description>
			<content:encoded><![CDATA[Last week I attended The Ajax Experience conference in Boston (no, I didn't go to a Red Sox game), sponsored by the folks at <a href="http://www.ajaxian.com">ajaxian.com</a> The schedule was packed with outstanding presentations. But the highlight of my trip was <a href="http://docs.jquery.com/JQueryCamp07">jQueryCamp07</a>, which was held at Harvard University on Saturday. 

Throughout the week I had quite a few opportunities to talk with John Resig, the creator and lead developer of jQuery. But, like the social clod that I am, I forgot to do the one thing that I had set out to do: Thank John Resig, in person, for the jQuery JavaScript Library. It was only after I returned home on Sunday that I realized my oversight. So, at the risk of sounding sappy, I figure I ought to write in a public forum what I had meant to say face to face. 
<span id="more-82"></span>
<i>Thanks, John, for creating an elegant, powerful tool that has saved me and thousands of others countless hours of frustration. jQuery has not only saved businesses enormous amounts of time and money by enabling web developers to write less code more quickly than we ever could have imagined, but it has also sparked a nascent industry of its own.</i> 

<i>Thanks for <a href="http://docs.jquery.com/JQueryCamp07">jQueryCamp07</a>, too. I really appreciate all the work you put into organizing the conference, securing a location, ordering the food, having the t-shirts printed &mdash; doing just about everything. It was great to meet people from the jQuery discussion list for the first time and hear about all the cool things they're doing with the library. I think it's safe to say that with 80+ people in attendance the conference was a huge success &mdash; especially considering how little (or no) advertising went into it.</i> 

Sorry if this post seems a little over the top, but the sentiments are genuine. It's remarkable that people like John are pouring themselves into these amazing tools, and then giving them away. Free. So others can profit. Still, I bet he wouldn't turn down a donation.
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" id="donate">
<fieldset>

  <input type="hidden" name="cmd" value="_xclick" />
  <input type="hidden" name="business" value="jeresig@gmail.com" />
  <input type="hidden" name="item_name" value="jQuery Donation" />
  <input type="hidden" name="item_number" value="JQUERY-DONATE" />
  <input type="hidden" name="no_note" value="1" />

  <input type="hidden" name="currency_code" value="USD" />
  <input type="hidden" name="return" value="http://jquery.com/" />
  <input type="hidden" name="tax" value="0" />
  <input type="hidden" name="lc" value="US" />
<p>Donate to jQuery</p>
  <label for="amount">Amount in $</a> <input type="text" name="amount" value="10.00" size="6" id="amount" /><br />
  <input type="submit" name="submit" value="Donate" />
</fieldset>
</form>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2007/10/thanks-for-jquery/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Improved Animated Scrolling Script for Same-Page Links</title>
		<link>http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links</link>
		<comments>http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links#comments</comments>
		<pubDate>Sat, 20 Oct 2007 19:20:30 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[DOM Modification]]></category>
		<category><![CDATA[DOM Traversing]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links</guid>
		<description><![CDATA[After posting the last entry on animated scrolling with jQuery 1.2, I realized that I had left out an important piece of code. Actually, I didn't discover it until someone notified me that another page on the site was broken. Can you spot the problem(s)? [Note: the problem is not in line 3. The syntax [...]]]></description>
			<content:encoded><![CDATA[<p>After posting <a href="/2007/09/animated-scrolling-with-jquery-12">the last entry on animated scrolling with jQuery 1.2</a>, I realized that I had left out an important piece of code. Actually, I didn't discover it until someone notified me that another page on the site was broken. Can you spot the problem(s)? [Note: the problem is <em>not</em> in line 3. The syntax highlighter just can't handle the regular expression with two slashes in it ("//") and is incorrectly treating them as a comment mark.] See the answer below the code.</p>

<div class="igBar"><span id="ljavascript-31"><a href="#" onclick="javascript:showPlainTxt('javascript-31'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-31">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href*=#]'</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=click"><span style="">click</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">pathname</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\//</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">pathname</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\//</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& location.<span style="color: #660066;">hostname</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hostname</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $target <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; $target <span style="color: #339933;">=</span> $target.<span style="color: #660066;">length</span> &#038;& $target</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #339933;">||</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name='</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=slice"><span style="">slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$target.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> targetOffset <span style="color: #339933;">=</span> $target.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=offset"><span style="">offset</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">top</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'html,body'</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=animate"><span style="">animate</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #339933;">:</span> targetOffset<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;color:#800000;">1000</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<span id="more-78"></span>
<p><strong>Answer</strong>: The animated scrolling script hijacks links that look like this: <code>&lt;a href="#"&gt;</code>. A couple people confirmed in the comments that the script needed a bit more work, so I figured we could take one more pass at it. </p>

<p>By the way, even though we attached the click event handler to all links that have the "#" symbol <em>anywhere</em> in the <code>href</code>, the very next line ensures that the link is pointing to the same page &mdash; by checking for a match between <code>location.pathname</code> and <code>this.pathname</code> &mdash; and the line after that ensures that it's pointing to the same domain, by checking for a match between <code>location.hostname</code> and <code>this.hostname</code>. With this approach, we can accommodate same-page links whether they include a fully-qualified URL, a relative URL, or just the fragment identifier.</p>

<h4>Check for the Hash</h4>
<p>Let's fix the problem with the <code>&lt;a href="#"&gt;</code> links. The first thing we have to do is see if there is actually something following the "#" symbol in the <code>href</code>. Apparently, if there is a lone "#" symbol, without any following characters, Firefox and Internet Explorer don't consider it a hash. Safari does, however. So, to avoid a false positive on <code>&lt;a href="#"&gt;</code>, we need to first strip the "#" and then check if there is anything left. We can do so by adding this condition to the first <code>if</code> statement: <code>&amp;&amp; this.hash.replace(/#/,'')</code></p>

<h4>Check for the Named Anchor</h4>
<p>Since we're already changing the script, maybe it's a good time to make some of it more readable, too. This part with the "short-circuit" logic, using <code>&amp;&amp;</code> and <code>||</code>, makes me a little dizzy:</p>

<div class="igBar"><span id="ljavascript-32"><a href="#" onclick="javascript:showPlainTxt('javascript-32'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-32">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #003366; font-weight: bold;">var</span> $target <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$target <span style="color: #339933;">=</span> $target.<span style="color: #660066;">length</span> &#038;& $target</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #339933;">||</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name='</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=slice"><span style="">slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$target.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
</ol></div>
</div></div><br />

<p>There is absolutely nothing wrong with this syntax. In fact, more advanced JavaScripters use it all the time. But I feel more comfortable using a simpler, more straightforward style. So, let's set two variables &mdash; one for a target ID and one for a target named anchor. We'll then use conditional (aka ternary) operators to set a third, <code>$target</code>, variable as the target ID if it's there, and if not, the target named anchor if it's there, and if not, <code>false</code>. Then we can just check if <code>$target</code> has some value (other than false):</p>

<div class="igBar"><span id="ljavascript-33"><a href="#" onclick="javascript:showPlainTxt('javascript-33'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-33">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #003366; font-weight: bold;">var</span> $targetId <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $targetAnchor <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name='</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=slice"><span style="">slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #003366; font-weight: bold;">var</span> $target <span style="color: #339933;">=</span> $targetId.<span style="color: #660066;">length</span> <span style="color: #339933;">?</span> $targetId </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #339933;">:</span> $targetAnchor.<span style="color: #660066;">length</span> <span style="color: #339933;">?</span> $targetAnchor </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
</ol></div>
</div></div><br />

<p>Now it appears that the animated scrolling behavior will be attached to all same-page links and not break other stuff on the page. </p>

<h4>Loop First, Bind Last</h4>
<p>But there is another problem. Since we're still binding the <code>.click()</code> method to every link with "#" in it, even if it's appropriately avoiding applying the animation for some of those links, jQuery is still hijacking links that have an inline <code>onclick</code> handler (but, oddly, only the first time those links are clicked). To fix this problem, we can replace the <code>.click()</code> with <code>.each()</code>. Then we'll iterate through all links that have "#" somewhere in them, but place the conditions inside the loop so that we bind the click handler only after we've filtered out all the links that don't apply. Here is what the script looks like with the change:</p>

<div class="igBar"><span id="ljavascript-34"><a href="#" onclick="javascript:showPlainTxt('javascript-34'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-34">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href*=#]'</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=each"><span style="">each</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">pathname</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\//</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">pathname</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\//</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& location.<span style="color: #660066;">hostname</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hostname</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/#/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $targetId <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> $targetAnchor <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name='</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=slice"><span style="">slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $target <span style="color: #339933;">=</span> $targetId.<span style="color: #660066;">length</span> <span style="color: #339933;">?</span> $targetId <span style="color: #339933;">:</span> $targetAnchor.<span style="color: #660066;">length</span> <span style="color: #339933;">?</span> $targetAnchor <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> targetOffset <span style="color: #339933;">=</span> $target.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=offset"><span style="">offset</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">top</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=click"><span style="">click</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'html, body'</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=animate"><span style="">animate</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #339933;">:</span> targetOffset<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;color:#800000;">400</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>Notice especially lines 2 and line 10. This change not only takes care of our problem, but it feels cleaner somehow, too. Is it more efficient? I don't know. Maybe someone else can tell us in the comments.</p>

<h4>Normalize Directory Indexes</h4>
<p>To be complete, we should probably take care of one more thing: the possibility that, on an "index" page, a link could point to "/path/index.htm" when the current location says "/path/" or vice versa. One way to "normalize" these index pages and links is to add a couple more <code>.replace()</code> methods to both sides of the equation in line 3.</p>

<h4>Update</h4>
<p>Aman suggested in a comment below that I make this process DRYer, and kangax provided a great example. So we can write a filter function and apply it to both sides rather than repeating the three replaces on each side:</p>

<div class="igBar"><span id="ljavascript-35"><a href="#" onclick="javascript:showPlainTxt('javascript-35'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-35">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #003366; font-weight: bold;">function</span> filterPath<span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> string</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\//</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> &nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(index|default).[a-zA-Z]{3,4}$/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #006600; font-style: italic;">// first additional replace </span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\/$/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>; &nbsp;<span style="color: #006600; font-style: italic;">// second additional replace</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span></div></li>
</ol></div>
</div></div><br />

<p>The first additional <code>.replace()</code> will find a string represented  by "index" or "default," followed by a dot, followed by any three or four letters at the end the pathname, and replace it with an empty string (i.e. remove it). The second one will replace a trailing slash with an empty string. As with chained jQuery methods, these regular-expression methods can be placed on separate lines to improve readability. Finally, we have a bullet-proof (I hope) animated scrolling script for same-page links:</p>

<div class="igBar"><span id="ljavascript-36"><a href="#" onclick="javascript:showPlainTxt('javascript-36'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-36">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">function</span> filterPath<span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> string</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\//</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> &nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(index|default).[a-zA-Z]{3,4}$/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> &nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\/$/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href*=#]'</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=each"><span style="">each</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> filterPath<span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">pathname</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> filterPath<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">pathname</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& location.<span style="color: #660066;">hostname</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hostname</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/#/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $targetId <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> $targetAnchor <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'[name='</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=slice"><span style="">slice</span></a><span style="color: #009900;">&#40;</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span><span style="color: #3366CC;">']'</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $target <span style="color: #339933;">=</span> $targetId.<span style="color: #660066;">length</span> <span style="color: #339933;">?</span> $targetId <span style="color: #339933;">:</span> $targetAnchor.<span style="color: #660066;">length</span> <span style="color: #339933;">?</span> $targetAnchor <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> targetOffset <span style="color: #339933;">=</span> $target.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=offset"><span style="">offset</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">top</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=click"><span style="">click</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'html, body'</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=animate"><span style="">animate</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #339933;">:</span> targetOffset<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;color:#800000;">400</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>If you try it out, let me know how it goes.</p>

<h4><ins datetime="2008-01-29T14:32:13+00:00">Update 2</ins></h4>
<p>Ariel Flesler has written an <a href="http://plugins.jquery.com/project/scrollto">excellent ScrollTo plugin</a>, which he says was inspired by this blog entry. Be sure to check out <a href="http://www.freewebs.com/flesler/jQuery.ScrollTo/">the demo</a>.</p>

<h4 id="update3"><ins datetime="2008-09-09T03:26:51+00:00">Update 3</ins></h4>
<p>Someone called my attention to a problem that this script was having in IE and Opera. Not sure how I could have missed that, because I'm sure I tested it in both of those browsers. But never mind, I've come up with a little patch:</p>

<div class="igBar"><span id="ljavascript-37"><a href="#" onclick="javascript:showPlainTxt('javascript-37'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-37">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">function</span> filterPath<span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> string</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\//</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(index|default).[a-zA-Z]{3,4}$/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\/$/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> locationPath <span style="color: #339933;">=</span> filterPath<span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">pathname</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href*=#]'</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=each"><span style="">each</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> thisPath <span style="color: #339933;">=</span> filterPath<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">pathname</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> locationPath;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> &nbsp;locationPath <span style="color: #339933;">==</span> thisPath</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& <span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">hostname</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hostname</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hostname</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/#/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $target <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> target <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> targetOffset <span style="color: #339933;">=</span> $target.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=offset"><span style="">offset</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">top</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=click"><span style="">click</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=event.preventDefault"><span style="">event.<span style="color: #660066;">preventDefault</span></span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'html, body'</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=animate"><span style="">animate</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #339933;">:</span> targetOffset<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;color:#800000;">400</span><span style="color: #339933;">,</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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; location.<span style="color: #660066;">hash</span> <span style="color: #339933;">=</span> target;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>Apparently, IE doesn't see a <code>hostname</code> or <code>pathname</code> if a link's <code>href</code> attribute is set with JavaScript and contains only a hash (such as "#example"). So, I'm checking now for either a match or an absence of <code>hostname</code> and <code>pathname</code>.</p>

<p>I hope this change fixes the problem that <a href="/2007/09/animated-scrolling-with-jquery-12#comment-54939">Mike</a> was having. Seems to work in my tests now. Oh, and I took the opportunity to improve the code a bit. Now, it has mild back-button support: while clicking on the back button doesn't produce the animated scrolling, it at least gets you back to the previous location.</p>

<h4 id="update4"><ins datetime="2009-01-16T04:11:27+00:00">Update 4</ins></h4>
<p>Ariel Flesler suggested that the problem a few people have mentioned regarding this script with Opera has to do with this line: <code> $('html, body').animate({scrollTop: targetOffset}, 400);</code> Here is a fix:</p>
<div class="igBar"><span id="ljavascript-38"><a href="#" onclick="javascript:showPlainTxt('javascript-38'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-38">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">function</span> filterPath<span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> string</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^\//</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/(index|default).[a-zA-Z]{3,4}$/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\/$/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> locationPath <span style="color: #339933;">=</span> filterPath<span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">pathname</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> scrollElem <span style="color: #339933;">=</span> scrollableElement<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'html'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[href*=#]'</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=each"><span style="">each</span></a><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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> thisPath <span style="color: #339933;">=</span> filterPath<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">pathname</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> locationPath;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> &nbsp;locationPath <span style="color: #339933;">==</span> thisPath</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& <span style="color: #009900;">&#40;</span>location.<span style="color: #660066;">hostname</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hostname</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hostname</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &#038;& <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/#/</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $target <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> target <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">hash</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>target<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> targetOffset <span style="color: #339933;">=</span> $target.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=offset"><span style="">offset</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">top</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=click"><span style="">click</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=event.preventDefault"><span style="">event.<span style="color: #660066;">preventDefault</span></span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span>scrollElem<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=animate"><span style="">animate</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #339933;">:</span> targetOffset<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;color:#800000;">400</span><span style="color: #339933;">,</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></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; location.<span style="color: #660066;">hash</span> <span style="color: #339933;">=</span> target;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #006600; font-style: italic;">// use the first element that is &quot;scrollable&quot;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">function</span> scrollableElement<span style="color: #009900;">&#40;</span>els<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;color:#800000;">0</span><span style="color: #339933;">,</span> argLength <span style="color: #339933;">=</span> arguments.<span style="color: #660066;">length</span>; i <span style="color: #339933;">&lt;</span>argLength; i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> el <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $scrollElement <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$scrollElement.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="">&gt;</span> <span style="color: #CC0000;color:#800000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> el;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; $scrollElement.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #009900;">&#40;</span><span style="color: #CC0000;color:#800000;">1</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> isScrollable <span style="color: #339933;">=</span> $scrollElement.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="">&gt;</span> <span style="color: #CC0000;color:#800000;">0</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; $scrollElement.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=scrollTop"><span style="">scrollTop</span></a><span style="color: #009900;">&#40;</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>isScrollable<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> el;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />
<p>I put together a little <a href="http://github.com/kswedberg/jquery-smooth-scroll">smooth-scroll jQuery plugin</a> with a couple options, in case anyone is interested. For a more robust feature set, check out Ariel Flesler's <a href="http://flesler.blogspot.com/2007/10/jqueryscrollto.html">scrollTo plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2007/10/improved-animated-scrolling-script-for-same-page-links/feed</wfw:commentRss>
		<slash:comments>123</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced (User agent is rejected)
Database Caching 8/43 queries in 0.011 seconds using disk: basic
Object Caching 630/712 objects using disk: basic
Content Delivery Network via learningjquery.kswedberg.netdna-cdn.com

Served from: www.learningjquery.com @ 2012-02-03 23:03:56 -->
