<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Viral Scripting</title>
	<atom:link href="http://viralscript.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://viralscript.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sun, 31 Aug 2008 00:23:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='viralscript.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Viral Scripting</title>
		<link>http://viralscript.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://viralscript.wordpress.com/osd.xml" title="Viral Scripting" />
	<atom:link rel='hub' href='http://viralscript.wordpress.com/?pushpress=hub'/>
		<item>
		<title>jQuery Basics</title>
		<link>http://viralscript.wordpress.com/2008/08/30/jquery-basics/</link>
		<comments>http://viralscript.wordpress.com/2008/08/30/jquery-basics/#comments</comments>
		<pubDate>Sat, 30 Aug 2008 22:23:39 +0000</pubDate>
		<dc:creator>Viral</dc:creator>
				<category><![CDATA[jQuery]]></category>
		<category><![CDATA[ECMAscript]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[viral]]></category>

		<guid isPermaLink="false">http://viralscript.wordpress.com/?p=6</guid>
		<description><![CDATA[When starting off with jQuery, you obviously need to know the basics, like the most common functions, the way you lay out the code, and the chaining. 1. Reason for use &#8211; jQuery is a widely used JavaScript library because it &#8216;closes the gap&#8217; with common cross-browser compatibilty in JavaScript. It simplifies many functions that [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viralscript.wordpress.com&amp;blog=4675535&amp;post=6&amp;subd=viralscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When starting off with jQuery, you obviously need to know the basics, like the most common functions, the way you lay out the code, and the chaining.</p>
<p>1. <strong>Reason for use &#8211; </strong>jQuery is a widely used JavaScript library because it &#8216;closes the gap&#8217; with common cross-browser compatibilty in JavaScript. It simplifies many functions that are already available in JavaScript and also adds it&#8217;s own ones that are easily used.</p>
<p>2. <strong>Chaining &#8211; </strong>If you have ever been reccomended jQuery by someone else, I am sure they used the term &#8216;chaining&#8217; somewhere in their persuasive speech. Why? Because chaining is the most useful advantage the jQuery library gives you. Here is an example of chaining:</p>
<blockquote><p><em>$(&#8220;#submenu&#8221;).html(&#8220;Hello World&#8221;).remove();</em></p></blockquote>
<p>In the above &#8216;snippet&#8217;, I have changed the innerHTML of the element with the ID &#8216;submenu&#8217; to &#8216;Hello World!&#8217; and then removed it from the page.<br />
The plain JavaScript variation of this is as follows:</p>
<blockquote><p><em>var submenu = document.getElementById(&#8220;submenu&#8221;);<br />
submenu.innerHTML = &#8220;Hello World!&#8221;;<br />
submenu.parentNode.removeChild(submenu);</em></p></blockquote>
<p>Now that&#8217;s a noticeable difference. When using jQuery effects like sliding and fading, the difference does become a lot greater, which we will work on later.</p>
<p>3. <strong>Basic Functions &#8211; </strong>As you have seen in the example I gave, I used 3 different functions.</p>
<ol>
<li><em>$(&#8220;&#8221;);</em></li>
<li><em>.html(&#8220;&#8221;);</em></li>
<li><em>.remove();</em></li>
</ol>
<ol>
<li>This is what starts the jQuery. From here on out, I&#8217;ll call it the selector. This nifty thing allows you to grab either one element from the page, or an array of elements and then reference it to any functions that follow in the chain. If you were to use:<br />
<blockquote><p><em>$(&#8220;<strong>.</strong>CSSclass&#8221;);</em></p></blockquote>
<p>That would select every element on the page that has the class <em>CSSclass</em>, notice the period ( <strong>.</strong> ).</p>
<blockquote><p><em>$(&#8220;<strong>#</strong>CSSid&#8221;);</em></p></blockquote>
<p>That selects every element on the page that has the ID <em>CSSid</em> although it should be noted that you should only use the same ID once, i.e no repititions of IDs. Notice the hash ( <strong>#</strong> ).</p>
<p>So we&#8217;ve looked at the jQuery alternatives to <em>document.getElementById()</em> and <em>document.getElementsByClassName()</em> (which is not in the DOM actually). The only other one is <em>document.getElementsByTagName()</em>. This also has an alternative in jQuery, much like the ID selector and the className selector, but you only use the name of the element. For example, if I wanted to grab all instances of the paragraph element, I would use:</p>
<blockquote><p><em>$(&#8220;p&#8221;);</em></p></blockquote>
<p>Notice that there is no period, hash, or anything else added, just the element name.</li>
<li>This is the innerHTML function. It works exactly as the plain JavaScript, <em>.innerHTML</em>.</li>
<li>This doesn&#8217;t have it&#8217;s own function in JavaScript, but it is normally referenced like so:<br />
<blockquote><p><em>var element = document.getElementById(&#8220;id&#8221;);<br />
element.parentNode.removeChild(element);</em></p></blockquote>
<p>This was also shown before, but just a little recap.</li>
</ol>
<p><strong>Recap on everything learned :</strong></p>
<blockquote><p><em> </em></p>
<ol>
<li><em>$(&#8220;&#8221;)</em></li>
<li><em>.html(&#8220;&#8221;);</em></li>
<li><em>.remove();</em></li>
</ol>
</blockquote>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/viralscript.wordpress.com/6/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/viralscript.wordpress.com/6/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/viralscript.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/viralscript.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/viralscript.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/viralscript.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/viralscript.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/viralscript.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/viralscript.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/viralscript.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/viralscript.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/viralscript.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/viralscript.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/viralscript.wordpress.com/6/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/viralscript.wordpress.com/6/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/viralscript.wordpress.com/6/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=viralscript.wordpress.com&amp;blog=4675535&amp;post=6&amp;subd=viralscript&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://viralscript.wordpress.com/2008/08/30/jquery-basics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/6116b45dd96fae61945a68ad232bb887?s=96&#38;d=identicon" medium="image">
			<media:title type="html">riverofrhyme</media:title>
		</media:content>
	</item>
	</channel>
</rss>
