<?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>vijayjoshi.org &#187; Javascript</title>
	<atom:link href="http://www.vijayjoshi.org/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vijayjoshi.org</link>
	<description>php &#124; javascript &#124; ajax &#124; and all things web</description>
	<lastBuildDate>Sun, 20 Nov 2011 15:24:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Why you MUST use client side validation</title>
		<link>http://www.vijayjoshi.org/2010/12/30/why-you-must-use-client-side-validation/</link>
		<comments>http://www.vijayjoshi.org/2010/12/30/why-you-must-use-client-side-validation/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 06:03:48 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[browser]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=931</guid>
		<description><![CDATA[
			
				
			
		

Client side validation is checking the values against the desired format before sending them to server side for further processing. Javascript is used for validations on browser. Lately, with the popularity of jQuery, a large number of validation plugins are available which make it even more easy to implement validations on forms.
A word of caution before beginning. Though client side ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F30%2Fwhy-you-must-use-client-side-validation%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F30%2Fwhy-you-must-use-client-side-validation%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="aligncenter size-full wp-image-947" title="validation" src="http://www.vijayjoshi.org/wp-content/uploads/validation.png" alt="validation" /></p>
<p>Client side validation is checking the values against the desired format before sending them to server side for further processing. Javascript is used for validations on browser. Lately, with the popularity of jQuery, a large number of validation plugins are available which make it even more easy to implement validations on forms.</p>
<p>A word of caution before beginning. Though client side validation is very useful and simple to implement, it should <strong>NEVER </strong>be thought of as a replacement for server side validations. If the javascript is turned off on the browser or user bypasses it and no server side validation is placed, your application then is at the mercy of users solely.</p>
<p><del datetime="2010-12-30T05:11:22+00:00">Read Why you must use server side validation?</del></p>
<p>So, here is why you should use client side validation.</p>
<h3>Easy to implement</h3>
<p>Although you can write your own validation for forms, there are multiple <a title="Javascript validation plugin" href="http://www.validationplugin.com/">javascript</a> and <a title="jQuery Validation" href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">jQuery</a> plugins available that require developers to write minimal amount of code to implement validation. These plugins also provide several options for customized validation like strings, numbers, dates, email addresses etc.</p>
<h3>No waiting time for users</h3>
<p>Since javascript executes on users browser itself, client side validation provides instant feedback. Plugins like <a title="Live Validation" href="http://livevalidation.com/">live validation</a> provide helpful messages to users as they type. Besides saving time, this pattern makes data entry less error prone.</p>
<h3>Less server trips</h3>
<p>Without javascript validation, each time a value needs to be checked, the form should be submitted and server would then process it and show the result. Take for example a text box which asks for email. Possible validations for it could be blank value and a valid email address. With javascript validations in place we can save these trips to server.</p>
<h3>Interactive and Fun</h3>
<p>Have a look at <a title="jQuery inline form validator" href="http://www.position-relative.net/creation/formValidator/">jQuery inline formValidator</a>. Gone are the days of ugly alert boxes (those were really irritating). With javascript running in browser, you can unleash your creativity and make validation an interactive and fun process by combining html and css with javascript. You can use tooltips and fancy effects to guide your users.</p>
<h3>Users love it</h3>
<p>Waiting for full page load only to see one error message is no good. Users like instant feedback and helpful error messages. Javascript allows you to create a rich visual experience that is a major trait of rich internet applications.</p>
<p>That&#8217;s it for now.</p>
<p>It is worth mentioning again that alone client side validation is no good. Always, I repeat, <strong>always use server side validation along with client side validation</strong>. This way, in case the javascript validation fails, you can always rely on the server.</p>
<p><a title="Form validation best practices" href="http://www.smashingmagazine.com/2009/07/07/web-form-validation-best-practices-and-tutorials/">Click here</a> to read more about best practices of form validation</p>
<div class="shr-publisher-931"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F30%2Fwhy-you-must-use-client-side-validation%2F' data-shr_title='Why+you+MUST+use+client+side+validation'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/30/why-you-must-use-client-side-validation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Filling a select box using javascript and jQuery</title>
		<link>http://www.vijayjoshi.org/2010/12/21/filling-a-select-box-using-javascript-and-jquery/</link>
		<comments>http://www.vijayjoshi.org/2010/12/21/filling-a-select-box-using-javascript-and-jquery/#comments</comments>
		<pubDate>Tue, 21 Dec 2010 08:25:22 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=861</guid>
		<description><![CDATA[
			
				
			
		
innerHTML is commonly used property for setting html content of elements. Though it is not a standard property, even then all browsers support it. It is faster then using DOM methods like createElement and appendChild.
You can use it to set html for almost all elements. In internet explorer there are some exceptions. You cannot set innerHTML for elements of a ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F21%2Ffilling-a-select-box-using-javascript-and-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F21%2Ffilling-a-select-box-using-javascript-and-jquery%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>innerHTML is commonly used property for setting html content of elements. Though it is not a standard property, even then all browsers support it. It is faster then using DOM methods like createElement and appendChild.</p>
<p>You can use it to set html for almost all elements. <strong>In internet explorer there are some exceptions. You cannot set innerHTML for <a title="innerHTML of a table" href="http://www.vijayjoshi.org/2008/07/28/internet-explorer-innerhtml-problem-while-adding-rows-in-table-with-javascript/">elements of a table</a> and <a title="innerHTML of select box" href="http://www.vijayjoshi.org/2008/10/05/setting-innerhtml-of-select-ie-screws-me-again/">select box</a>.</strong></p>
<p>Recently a reader asked me the workaround for setting options inside a select box with the help of javascript or jQuery. In this post I will explain some methods which you can use as an alternate to innerHTML.</p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_453" class="wp-caption aligncenter" style="width: 190px;">
<dt class="wp-caption-dt"><a href="http://www.vijayjoshi.org/examples/fillSelectBox.html"><img class="size-full wp-image-453" title="demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></a></dt>
</dl>
</div>
<p>Here is a html select box.</p>
<pre class="brush:html">&lt;select id="selectBox"&gt;
&lt;/select&gt;</pre>
<p>Now let us look at various options available to us.</p>
<p><span id="more-861"></span></p>
<h3>Using innerHTML</h3>
<p>This is the problem. This method will work in all browsers except IE (i have tested till IE8).</p>
<pre class="brush:js">var select = document.getElementById('selectBox');
var options = '&lt;option&gt;option 1&lt;/option&gt;';
options+= '&lt;option&gt;option 2&lt;/option&gt;';
options+= '&lt;option&gt;option 3&lt;/option&gt;';
select.innerHTML = options;</pre>
<h3>Using DOM &#8211; Works in all browsers</h3>
<pre class="brush:js">var select = document.getElementById('selectBox');
for(var i=0; i&lt;3; i++)
{
	var option = document.createElement('option');
	option.appendChild(document.createTextNode('option' + i));
	select.appendChild(option);
}</pre>
<h3>Using jQuery</h3>
<p>Method 1- This will work in all browsers.</p>
<pre class="brush:js">$('#selectBox').append('&lt;option&gt;an option&lt;/option&gt;');
$('#selectBox').append('&lt;option&gt;another option&lt;/option&gt;');
$('#selectBox').append('&lt;option&gt;yet another option&lt;/option&gt;');</pre>
<p>append method appends the html at the end of an element.</p>
<h3>Using jQuery</h3>
<p>Method 2 &#8211; This will also work in all browsers.</p>
<pre class="brush:js">var options = '&lt;option&gt;option 1&lt;/option&gt;';
options+= '&lt;option&gt;option 2&lt;/option&gt;';
options+= '&lt;option&gt;option 3&lt;/option&gt;';
$('#selectBox').html(options);</pre>
<p>html() method in jQuery can be thought of as a counterpart of the innerHTML property.</p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_453" class="wp-caption aligncenter" style="width: 190px;">
<dt class="wp-caption-dt"><a href="http://www.vijayjoshi.org/examples/fillSelectBox.html"><img class="size-full wp-image-453" title="demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></a></dt>
</dl>
</div>
<p>That is all folks. Hope it helps you. If you know of any other technique, do let me know in comments.</p>
<div class="shr-publisher-861"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F21%2Ffilling-a-select-box-using-javascript-and-jquery%2F' data-shr_title='Filling+a+select+box+using+javascript+and+jQuery'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/21/filling-a-select-box-using-javascript-and-jquery/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>8 blogs you must read if you are a web developer</title>
		<link>http://www.vijayjoshi.org/2010/12/19/8-blogs-you-must-read-if-you-are-a-web-developer/</link>
		<comments>http://www.vijayjoshi.org/2010/12/19/8-blogs-you-must-read-if-you-are-a-web-developer/#comments</comments>
		<pubDate>Sat, 18 Dec 2010 20:55:15 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Resources]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=782</guid>
		<description><![CDATA[
			
				
			
		
Ajaxian
Ajaxian covers all news related to javascript, libraries, AJAX related news, technologies, libraries, browsers quirks etc.
Why?
Definitive resource for AJAX whether you use it with PHP, Perl, NET(argh!) or whatever else. This blog should not be missed.
A List Apart
This is a classic one. The creators of this web magazine call it &#8220;For people who make websites&#8221;.
A List Apart Magazine explores the ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F19%2F8-blogs-you-must-read-if-you-are-a-web-developer%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F19%2F8-blogs-you-must-read-if-you-are-a-web-developer%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<h2><a title="Ajaxian" href="http://ajaxian.com/">Ajaxian</a></h2>
<p><a href="http://ajaxian.com/"><img class="size-full wp-image-773 alignleft" title="Ajaxian" src="http://www.vijayjoshi.org/wp-content/uploads/1-ajaxian.gif" alt="Ajaxian" width="173" height="120" /></a>Ajaxian covers all news related to javascript, libraries, AJAX related news, technologies, libraries, browsers quirks etc.</p>
<p><strong>Why?</strong></p>
<p>Definitive resource for AJAX whether you use it with PHP, Perl, NET(argh!) or whatever else. This blog should not be missed.</p>
<h2><a title="A List Apart" href="http://www.alistapart.com/">A List Apart</a></h2>
<p>This is a classic one. <a href="http://www.alistapart.com/"><img class="size-full wp-image-774 alignright" style="display: block;" title="A List Apart" src="http://www.vijayjoshi.org/wp-content/uploads/2-alistapart.gif" alt="2-alistapart" width="142" height="182" /></a>The creators of this web magazine call it &#8220;For people who make websites&#8221;.</p>
<blockquote><p>A List Apart Magazine explores the design, development, and meaning of web content, with a special focus on web standards and best practices.</p></blockquote>
<p><strong>Why?</strong></p>
<p>If you want to know all about building websites including design, code, writing compelling content and project management, this is the place.</p>
<h2><a title="Cats Who Code" href="http://www.catswhocode.com/blog/">Cats Who Code</a></h2>
<p><a href="http://www.catswhocode.com/blog/"><img class="size-full wp-image-794 alignleft" title="Cats Who Code" src="http://www.vijayjoshi.org/wp-content/uploads/3-catswhocode.png" alt="Cats Who Code" width="307" height="127" /></a>Cats Who Code is a blog by Jean-Baptiste Jung who is a web developer and professional blogger.</p>
<p><strong>Why?</strong></p>
<p>For lots of helpful code snippets, lists and hacks on PHP, jQuery and definitive information on a variety of wordpress topics.</p>
<h2><a title="CSS-Tricks" href="http://css-tricks.com/">CSS-Tricks</a></h2>
<p><a href="http://css-tricks.com/"><img class="size-full wp-image-795 alignright" title="CSS-Tricks" src="http://www.vijayjoshi.org/wp-content/uploads/4-csstricks.png" alt="4-csstricks" width="265" height="135" /></a>CSS-Tricks is a website by renowned design ninja Chris Coyer where he shares his CSS secrets.</p>
<p><strong>Why?</strong></p>
<p>For detailed articles on how css works, browser hacks, cross browser compatibility and HTML 5.</p>
<h2><a title="Nettuts+" href="http://net.tutsplus.com/">Nettuts+</a></h2>
<p><a href="http://net.tutsplus.com/"><img class="size-full wp-image-796 alignleft" title="Nettuts" src="http://www.vijayjoshi.org/wp-content/uploads/5-nettuts.png" alt="5-nettuts" width="220" height="120" /></a>A part of Tuts+ Network, this site contains tutorials and screencasts on HTML, CSS, Javascript/jQuery, PHP, Ruby on Rails etc.Though most of the articles are free, it also publishes premium tutorials which are available for a small fee.</p>
<p><strong>Why?</strong><br />
High quality articles that explain each topic step by step in detail and are very easy to follow even for a beginner.</p>
<p><span id="more-782"></span></p>
<h2><a title="PHPDeveloper" href="http://www.phpdeveloper.org/">PHPDeveloper</a><a href="http://www.phpdeveloper.org/"><img class="alignright size-full wp-image-797" title="PHPDeveloper" src="http://www.vijayjoshi.org/wp-content/uploads/6-phpdeveloper.png" alt="6-phpdeveloper" width="263" height="143" /></a></h2>
<p>This site has been around for a long time and is a trustworthy source for news that is all PHP. Besides news, it also updates users about php conferences, jobs and new web technologies regularly.</p>
<p><strong>Why?</strong></p>
<p>All awesome news of PHP at on place.</p>
<h2><a title="Six Revisions" href="http://sixrevisions.com/">Six Revisions</a></h2>
<p><a href="http://sixrevisions.com/"><img class="alignleft size-full wp-image-798" title="Six Revisions" src="http://www.vijayjoshi.org/wp-content/uploads/7-sixrevisions.png" alt="7-sixrevisions" width="294" height="61" /></a>Despite the fact that this site is only 3 years old, it already has made a reputed name in community. It was founded by Jacob Gube who himself is a designer/developer, this blog now publishes web design related articles of authors from all over the world.</p>
<p><strong>Why?</strong></p>
<p>For high quality resources and articles on web design and development, web standards.</p>
<h2><a title="Smashing Magazine" href="http://www.smashingmagazine.com/">Smashing Magazine</a><a href="http://www.smashingmagazine.com/"><img class="alignright size-full wp-image-780" title="Smashing Magazine" src="http://www.vijayjoshi.org/wp-content/uploads/8-SmashingMagazine.jpg" alt="8-SmashingMagazine" width="227" height="194" /></a></h2>
<p>Founded by German designers Sven Lennartz &amp; Vitaly Friedman, for the past 4 years smashing magazine has been publishing high quality articles on web design. SM has also created what it calls &#8220;Smashing Network&#8221;. Smashing network is a channel of 30+ web development/design blogs.</p>
<p><strong>Why?</strong></p>
<p>Insightful and innovative articles focused primarily on web design. Very high quality content and free goodies like wallpapers, themes and wordpress themes.</p>
<h2>Bonus</h2>
<p>Every year in December many sites create an advent calendar that publishes 1 article per day starting from 1st of December till Christmas. Below are 2 of my favorites.</p>
<p><strong>24 ways &#8211; <a href="http://24ways.org/">http://24ways.org/</a></strong></p>
<p>24 ways started out in 2005. Here is the excerpt from the site itself.</p>
<blockquote><p><strong>24 ways</strong> is the advent calendar for web geeks. Each day throughout December we publish a daily dose of web design and development goodness to bring you all a little Christmas cheer.</p></blockquote>
<p><strong>PHP Advent</strong> &#8211; <a title="PHP Advent" href="http://phpadvent.org/">http://phpadvent.org/</a></p>
<p>Curated by Chris Shiflett &amp; Sean Coates, PHP advent started in 2008. Since then, it has been publishing articles on PHP and related technologies each year till Christmas in the month of December.</p>
<p>All article are written by well known developers and experts.</p>
<div class="shr-publisher-782"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F12%2F19%2F8-blogs-you-must-read-if-you-are-a-web-developer%2F' data-shr_title='8+blogs+you+must+read+if+you+are+a+web+developer'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/12/19/8-blogs-you-must-read-if-you-are-a-web-developer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery Tip: Finding tag name of an element</title>
		<link>http://www.vijayjoshi.org/2010/11/20/jquery-tip-finding-tag-name-of-an-element/</link>
		<comments>http://www.vijayjoshi.org/2010/11/20/jquery-tip-finding-tag-name-of-an-element/#comments</comments>
		<pubDate>Sat, 20 Nov 2010 05:30:02 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[FAQ]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=644</guid>
		<description><![CDATA[
			
				
			
		
While coding jQuery or javascript, sometimes we need the tag name of an element. This post will show how you can retrieve the tag name of an element easily using jQuery
We know that each DOM element has a tagName property. We also know that most jQuery methods return jQuery object. Therefore to get the tagName, we need to extract the ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F20%2Fjquery-tip-finding-tag-name-of-an-element%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F20%2Fjquery-tip-finding-tag-name-of-an-element%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>While coding jQuery or javascript, sometimes we need the tag name of an element. This post will show how you can retrieve the tag name of an element easily using jQuery</p>
<p>We know that each DOM element has a <em>tagName </em>property. We also know that most jQuery methods return jQuery object. Therefore to get the tagName, we need to extract the DOM element from it. This can be achieved in 2 ways.</p>
<p><strong>Method 1: Using get() method of jQuery</strong></p>
<p>jQuery&#8217;s <em>get()</em> method returns the collection of DOM elements for a jQuery collection.</p>
<p>Consider the following markup</p>
<pre class="brush:html">
<div id="firstDiv">This is a div</div>
</pre>
<p><span id="more-644"></span><br />
In this case <em>$(&#8216;#firstDiv&#8217;)</em> will be the jQuery object for above div. To get tag name for correspoding DOM element use the following</p>
<pre lang="javascript">var element = $('#firstDiv').get(0);
var tagName = element.tagName;</pre>
<p>Note that get() returns an array, hence 0 based indexes to retrieve elements. Have a look at another example.</p>
<pre class="brush:html">
<div id="secondDiv">
<input type="text" value="text box" />

paragraph element

    <span>span element</span>
</div>
</pre>
<pre class="brush:js">var a = $('#secondDiv').children().get(0); // INPUT
var b = $('#secondDiv').children().get(1); // P
var c = $('#secondDiv').children().get(2); // SPAN</pre>
<p><strong>Method 2: Using this</strong></p>
<p>You can also use this to refer to DOM elements as shown in next example. Code below use the same markup for secondDiv.</p>
<pre class="brush:js">$('#secondDiv').children().each(function()
{
	var tagName = (this.tagName).toLowerCase();
});</pre>
<p>The returned tag names will all be in uppercase. You can use javascript function toLowerCase to make them XHTML compliant i.e. lower case.</p>
<div class="shr-publisher-644"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F20%2Fjquery-tip-finding-tag-name-of-an-element%2F' data-shr_title='jQuery+Tip%3A+Finding+tag+name+of+an+element'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/11/20/jquery-tip-finding-tag-name-of-an-element/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>61 jQuery Image and gallery plugins</title>
		<link>http://www.vijayjoshi.org/2010/11/11/list-of-61-jquery-image-and-gallery-plugins/</link>
		<comments>http://www.vijayjoshi.org/2010/11/11/list-of-61-jquery-image-and-gallery-plugins/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 09:57:30 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=492</guid>
		<description><![CDATA[
			
				
			
		
Presenting list of 61 jQuery plugins for galleries and slideshows. All of them are different and you can choose from them depending on the project you are working on.
If you come across any plugin which I have  not included here, please take a moment to add it in comments. I will update the post. The list is in alphabetical order.


AD ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F11%2Flist-of-61-jquery-image-and-gallery-plugins%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F11%2Flist-of-61-jquery-image-and-gallery-plugins%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Presenting list of 61 jQuery plugins for galleries and slideshows. All of them are different and you can choose from them depending on the project you are working on.</p>
<p>If you come across any plugin which I have  not included here, please take a moment to add it in comments. I will update the post. The list is in alphabetical order.</p>
<p><img class="aligncenter size-full wp-image-623" title="1gallery" src="http://www.vijayjoshi.org/wp-content/uploads/1gallery.png" alt="1gallery" /></p>
<ul>
<li><strong><a title="AD Gallery" href="http://coffeescripter.com/code/ad-gallery/ ">AD Gallery</a></strong></li>
<li><strong><a title="BarackSlideshow" href="http://devthought.com/wp-content/projects/mootools/barackslideshow/Demo/">BarackSlideshow</a></strong></li>
<li><strong><a title="CeeBox" href="http://catcubed.com/2008/12/23/ceebox-a-thickboxvideobox-mashup/">CeeBox</a></strong></li>
<li><strong><a title="ColorBox" href="http://colorpowered.com/colorbox/">ColorBox</a></strong></li>
<li><strong><a title="Create a Resizable Image Grid with jQuery" href="http://webdesignledger.com/tutorials/create-a-resizable-image-grid-with-jquery">Create a Resizable Image Grid with jQuery</a></strong></li>
<li><strong><a title="Create Beautiful jQuery slider tutorial" href="http://www.dreamcss.com/2009/04/create-beautiful-jquery-sliders.html">Create Beautiful jQuery slider tutorial</a></strong></li>
<li><strong><a title="CrossSlide" href="http://www.gruppo4.com/~tobia/cross-slide.shtml">CrossSlide</a></strong></li>
<li><strong><a title="Easy Slider" href="http://cssglobe.com/post/4004/easy-slider-15-the-easiest-jquery-plugin-for-sliding">Easy Slider</a></strong></li>
<li><strong><a title="EOGallery " href="http://www.eogallery.com/">EOGallery </a></strong></li>
<li><strong><a title="Facebox" href="http://famspam.com/facebox">Facebox</a></strong></li>
<li><strong><a title="Fancy Thumbnail Hover Effect" href="http://www.sohtanaka.com/web-design/fancy-thumbnail-hover-effect-w-jquery/">Fancy Thumbnail Hover Effect</a></strong></li>
<li><strong><a title="FancyBox" href="http://fancy.klade.lv/">FancyBox</a></strong></li>
<li><strong><a title="FancyZoom" href="http://orderedlist.com/articles/fancyzoom-meet-jquery">FancyZoom</a></strong></li>
<li><strong><a title="Flickr Gallery" href="http://www.userfriendlythinking.com/Blog/BlogDetail.asp?p1=7013&amp;p2=101&amp;p7=3001">Flickr Gallery</a></strong></li>
<li><strong><a title="Galleria" href="http://devkick.com/lab/galleria/">Galleria</a></strong></li>
</ul>
<p><span id="more-492"></span></p>
<ul>
<li><strong><a title="Galleriffic" href="http://www.twospy.com/galleriffic/index.html">Galleriffic</a></strong></li>
<li><strong><a title="GalleryView " href="http://spaceforaname.com/galleryview">GalleryView </a></strong></li>
<li><strong><a title="Greybox Redux" href="http://jquery.com/demo/grey/">Greybox Redux</a></strong></li>
<li><strong><a title="Image Flow" href="http://cool-javascripts.com/effects/image-flow-09.html">Image Flow</a></strong></li>
<li><strong><a title="Image Gallery by qd-creative" href="http://enhance.qd-creative.co.uk/2008/07/12/an-image-gallery/">Image Gallery by qd-creative</a></strong></li>
<li><strong><a title="ImageBox" href="http://www.intelliance.fr/jquery/imagebox/">ImageBox</a></strong></li>
<li><strong><a title="ImageCube" href="http://keith-wood.name/imageCube.html">ImageCube</a></strong></li>
<li><strong><a title="Innerfade" href="http://medienfreunde.com/lab/innerfade/">Innerfade</a></strong></li>
<li><strong><a title="Interface Imagebox" href="http://www.intelliance.fr/jquery/imagebox/">Interface Imagebox</a></strong></li>
<li><strong><a title="jFlow" href="http://net.tutsplus.com/javascript-ajax/using-the-wonderful-jflow-plugin-screencast/">jFlow</a></strong></li>
<li><strong><a title="jQuery Cycle" href="http://malsup.com/jquery/cycle/">jQuery Cycle</a></strong></li>
<li><strong><a title="jQuery Gallery Plugin" href="http://www.mudaimemo.com/p/gallery/">jQuery Gallery Plugin</a></strong></li>
<li><strong><a title="jQuery Gallery Scroller" href="http://benjaminsterling.com/jquery-jqgalscroll-photo-gallery/">jQuery Gallery Scroller</a></strong></li>
<li><strong><a title="jQuery Image Strip" href="http://blog.joshuaeichorn.com/archives/2007/01/11/jquery-image-strip/">jQuery Image Strip</a></strong></li>
</ul>
<p><img class="aligncenter size-full wp-image-624" title="2galleriffic" src="http://www.vijayjoshi.org/wp-content/uploads/2galleriffic.png" alt="2galleriffic" /></p>
<ul>
<li><strong><a title="jQuery Lightbox" href="http://leandrovieira.com/projects/jquery/lightbox/">jQuery Lightbox</a></strong></li>
<li><strong><a title="jQuery PanelGallery" href="http://www.catchmyfame.com/2009/08/13/jquery-panel-gallery-1-1-plugin-released/">jQuery PanelGallery</a></strong></li>
<li><strong><a title="jQuery spherical panorama viewer" href="http://www.openstudio.fr/jQuery-spherical-panorama-viewer.html?lang=en">jQuery spherical panorama viewer</a></strong></li>
<li><strong><a title="jQuery Virtual Tour" href="http://www.openstudio.fr/jquery-virtual-tour/">jQuery Virtual Tour</a></strong></li>
<li><strong><a title="JQZoom " href="http://www.mind-projects.it/projects/jqzoom/">JQZoom </a></strong></li>
<li><strong><a title="Moving Boxes" href="http://css-tricks.com/examples/MovingBoxes/">Moving Boxes</a></strong></li>
<li><strong><a title="nyroModal" href="http://nyromodal.nyrodev.com/">nyroModal</a></strong></li>
<li><strong><a title="panView" href="http://motherrussia.polyester.se/jquery/panview/">panView</a></strong></li>
<li><strong><a title="PictureSlides " href="http://www.robertnyman.com/picture-slides/index.htm">PictureSlides </a></strong></li>
<li><strong><a title="Pikachoose" href="http://pikachoose.com/">Pikachoose</a></strong></li>
<li><strong><a title="Pirobox" href="http://www.pirolab.it/pirobox/">Pirobox</a></strong></li>
<li><strong><a title="Polaroid Photo Viewer" href="http://demo.marcofolio.net/polaroid_photo_container/">Polaroid Photo Viewer</a></strong></li>
<li><strong><a title="Popeye" href="http://dev.herr-schuessler.de/examples/jquery-popeye-1-0/">Popeye</a></strong></li>
<li><strong><a title="prettyPhoto" href="http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/">prettyPhoto</a></strong></li>
<li><strong><a title="s3Slider" href="http://www.serie3.info/s3slider/">s3Slider</a></strong></li>
<li><strong><a title="ScrollShow " href="http://flesler.blogspot.com/search/label/jQuery.ScrollShow">ScrollShow </a></strong></li>
<li><strong><a title="Sexy Lightbox2" href="http://www.coders.me/web-html-js-css/javascript/sexy-lightbox-2">Sexy Lightbox2</a></strong></li>
<li><strong><a title="Shadowbox" href="http://www.shadowbox-js.com/index.html">Shadowbox</a></strong></li>
<li><strong><a title="Simple Controls Image Gallery" href="http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm">Simple Controls Image Gallery</a></strong></li>
<li><strong><a title="Simple jQuery Slideshow" href="http://jonraasch.com/blog/a-simple-jquery-slideshow">Simple jQuery Slideshow</a></strong></li>
<li><strong><a title="slideViewer" href="http://www.gcmingati.net/wordpress/wp-content/lab/jquery/imagestrip/imageslide-plugin.html">slideViewer</a></strong></li>
<li><strong><a title="Sliding Image Gallery" href="http://www.meadmiracle.com/SlidingGallery.aspx">Sliding Image Gallery</a></strong></li>
<li><strong><a title="Slightly ThickerBox" href="http://www.jasons-toolbox.com/SlightlyThickerbox/">Slightly ThickerBox</a></strong></li>
<li><strong><a title="Smooth Div Scroll" href="http://www.maaki.com/thomas/SmoothDivScroll/">Smooth Div Scroll</a></strong></li>
<li><strong><a title="Spacegallery" href="http://eyecon.ro/spacegallery/#download">Spacegallery</a></strong></li>
<li><strong><a title="Start/Stop Slider" href="http://css-tricks.com/examples/StartStopSlider/">Start/Stop Slider</a></strong></li>
<li><strong><a title="Step Carousel Viewer" href="http://www.dynamicdrive.com/dynamicindex4/stepcarousel.htm">Step Carousel Viewer</a></strong></li>
<li><strong><a title="Supersized" href="http://buildinternet.com/2009/02/supersized-full-screen-backgroundslideshow-jquery-plugin/">Supersized</a></strong></li>
<li><strong><a title="ThickBox Gallery" href="http://jquery.com/demo/thickbox/">ThickBox Gallery</a></strong></li>
<li><strong><a title="TopUp" href="http://gettopup.com/">TopUp</a></strong></li>
<li><strong><a title="Ultimate Fade In Slide Show" href="http://www.dynamicdrive.com/dynamicindex14/fadeinslideshow.htm">Ultimate Fade In Slide Show</a></strong></li>
<li><strong><a title="Zoomimage" href="http://eyecon.ro/zoomimage/">Zoomimage</a></strong></li>
</ul>
<p><img class="aligncenter size-full wp-image-625" title="3jflow" src="http://www.vijayjoshi.org/wp-content/uploads/3jflow.png" alt="3jflow" /></p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<table style="border-collapse: collapse; width: 90pt;" border="0" cellspacing="0" cellpadding="0" width="120">
<col style="width: 90pt;" width="120"></col>
<tbody>
<tr style="height: 12.75pt;" height="17">
<td class="xl63" style="height: 12.75pt; width: 90pt;" width="120" height="17">AD   Gallery</td>
</tr>
</tbody>
</table>
</div>
<div class="shr-publisher-492"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F11%2F11%2Flist-of-61-jquery-image-and-gallery-plugins%2F' data-shr_title='61+jQuery+Image+and+gallery+plugins'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/11/11/list-of-61-jquery-image-and-gallery-plugins/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>5 must have firefox addons for every web developer</title>
		<link>http://www.vijayjoshi.org/2010/01/21/5-must-have-firefox-addons-for-every-web-developer/</link>
		<comments>http://www.vijayjoshi.org/2010/01/21/5-must-have-firefox-addons-for-every-web-developer/#comments</comments>
		<pubDate>Thu, 21 Jan 2010 05:24:58 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[IE]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=509</guid>
		<description><![CDATA[
			
				
			
		
Being a web developer there are some tools which I need and use on daily basis. Here are 5 such addons I think every web developer should install on their firefox.
1- Web developer toolbar

Home: http://chrispederick.com/work/web-developer/
Install: https://addons.mozilla.org/en-US/firefox/addon/60


 


This addon adds a toolbar and a menu to firefox. The toolbar contains several mini tools in it to perform various tasks. It has ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F01%2F21%2F5-must-have-firefox-addons-for-every-web-developer%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F01%2F21%2F5-must-have-firefox-addons-for-every-web-developer%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p class="mceTemp mceIEcenter" style="text-align: left;">Being a web developer there are some tools which I need and use on daily basis. Here are 5 such addons I think every web developer should install on their firefox.</p>
<h3 class="mceTemp mceIEcenter" style="text-align: left;">1- Web developer toolbar</h3>
<p class="mceTemp mceIEcenter" style="text-align: left;">
<p class="mceTemp mceIEcenter" style="text-align: left;"><strong>Home: </strong><a href="http://chrispederick.com/work/web-developer/" target="_self">http://chrispederick.com/work/web-developer/</a></p>
<p class="mceTemp mceIEcenter" style="text-align: left;"><strong>Install: </strong><a href="https://addons.mozilla.org/en-US/firefox/addon/60" target="_self">https://addons.mozilla.org/en-US/firefox/addon/60</a></p>
<p><img class="size-full wp-image-505 " style="border: 1px solid black;" title="web-developer" src="http://www.vijayjoshi.org/wp-content/uploads/web-developer.png" alt="Web Developer Toolbar" width="545" height="381" /></p>
<div class="mceTemp mceIEcenter">
<dl id="attachment_505" class="wp-caption aligncenter" style="width: 555px;"> </dl>
</div>
<p style="text-align: left;">
<p style="text-align: left;">This addon adds a toolbar and a menu to firefox. The toolbar contains several mini tools in it to perform various tasks. It has 11 built in menus for different tasks like cookies, css, forms, html, images and many others. You can read a review of web developer toolbar <a href="http://tips.webdesign10.com/web-developer-toolbar.htm" target="_self">here</a>.</p>
<p style="text-align: left;">
<p style="text-align: left;">
<h3 style="text-align: left;">2- JSONView<strong> </strong></h3>
<p style="text-align: left;">
<p style="text-align: left;"><strong>Home: </strong><a href="http://benhollis.net/blog/2009/02/24/jsonview-view-json-documents-in-firefox/" target="_self">http://benhollis.net/blog/2009/02/24/jsonview-view-json-documents-in-firefox/</a></p>
<p><strong>Install: </strong><a href="https://addons.mozilla.org/en-US/firefox/addon/10869" target="_self">https://addons.mozilla.org/en-US/firefox/addon/10869</a></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-508" style="border: 1px solid black;" title="jsonview" src="http://www.vijayjoshi.org/wp-content/uploads/jsonview.png" alt="" width="315" height="375" /></p>
<p style="text-align: left;">JSON is becoming more popular day by day as a data exchange format. JSONView allows you to view json documents in the browser itself without having to open in any text editor and format it. Local files can also be seen if they have .json extension. It formats the document nicely and also provides options to collapse/expand nodes too (just like XML).<br />
In case of invalid json it reports an error.</p>
<p style="text-align: left;">
<p style="text-align: left;">
<h3>3- Fireftp</h3>
<p style="text-align: left;">
<p style="text-align: left;"><strong> Home: </strong><a href="http://fireftp.mozdev.org/" target="_self">http://fireftp.mozdev.org/</a></p>
<p style="text-align: left;"><strong> Install: </strong><a href="https://addons.mozilla.org/en-US/firefox/addon/684" target="_self">https://addons.mozilla.org/en-US/firefox/addon/684</a></p>
<p style="text-align: center;">
<p style="text-align: center;"><img class="aligncenter size-full wp-image-507" title="fireftp" src="http://www.vijayjoshi.org/wp-content/uploads/fireftp.png" alt="" width="590" height="420" /></p>
<p style="text-align: left;">You will not have to open a separate ftp client if you use this. To open Fire FTP, go to <strong>Tools -&gt; Fire FTP</strong> on firefox menu bar. It opens an easy to use interface in a new tab. You can create multiple accounts and you will get all the features that you expect from a ftp client.</p>
<p style="text-align: left;"><strong>From the site: </strong>&#8220;Along with transferring your files quickly and efficiently, FireFTP also includes more advanced features such as: directory comparison, syncing directories while navigating, SFTP, SSL encryption, search/filtering, integrity checks, remote editing, drag &amp; drop, file hashing, and much more!&#8221;</p>
<p style="text-align: left;"><strong><span id="more-509"></span></strong></p>
<p style="text-align: left;">
<h3>4- IE Tab</h3>
<p style="text-align: left;">
<p style="text-align: left;"><strong>Home: </strong><a href="http://ietab.mozdev.org/" target="_self">http://ietab.mozdev.org/</a></p>
<p style="text-align: left;"><strong> Install: </strong><a href="https://addons.mozilla.org/en-US/firefox/addon/1419" target="_self">https://addons.mozilla.org/en-US/firefox/addon/1419</a></p>
<p style="text-align: left;">
<p style="text-align: left;">Use IE tab if you want to check display of your web pages in Internet explorer. Instead of opening IE separately, it will open a tab in firefox which will display your page using the IE engine installed on your machine.  It will put an icon on your status bar using which you can switch engines.</p>
<p style="text-align: center;">
<h3>5- Firebug</h3>
<p style="text-align: left;">
<p style="text-align: left;"><strong>Home: </strong><a href="http://getfirebug.com/" target="_self">http://getfirebug.com/</a></p>
<p style="text-align: left;"><strong>Install: </strong><a href="https://addons.mozilla.org/en-US/firefox/addon/1843" target="_self">https://addons.mozilla.org/en-US/firefox/addon/1843</a></p>
<p style="text-align: center;">
<p style="text-align: center;"><img class="aligncenter size-full wp-image-506" title="firebug" src="http://www.vijayjoshi.org/wp-content/uploads/firebug.png" alt="firebug" width="590" height="280" /></p>
<p style="text-align: left;">
<p style="text-align: left;">How can a firefox addons list be complete without Firebug. <strong> </strong></p>
<p style="text-align: left;"><strong>From the site:</strong> &#8220;Firebug integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.&#8221;</p>
<p style="text-align: left;">Firebug needs no inroduction to web developers. It reduces the development time to a great extent, specially if your application relies on javascript/ajax too much. It provides rock solid debugging for javascript where you can add/remove breakpoints, watch variables in real time and much more.</p>
<p style="text-align: left;">Want more? You can inspect and edit html/css on the fly to change the look and feel of a page. You can also check the download time for your css files,scripts, images and html pages using the net tab which are helpful for optimizations.</p>
<p style="text-align: left;">Firbug has a number of addons too (yes! addons for an addon). I recommend both the addons given below.</p>
<p><strong>Page Speed </strong>: It is an addon from Google which is used to analyze the loading performance of a page. It tests a page against Web Performance Best Practices which you can <a href="http://code.google.com/speed/page-speed/docs/rules_intro.html" target="_self">read here</a>. After this a score out of 100 is provided. Greater score means faster page load. Install it from <a href="http://code.google.com/speed/page-speed/download.html" target="_self">this link</a>.</p>
<p><strong>YSlow: </strong>YSlow is a addon similar to Page Speed. It is created by Yahoo. YSlow measures a web page&#8217;s performance against a set of rules for high performance pages created by Yahoo. You can <a href="https://addons.mozilla.org/en-US/firefox/addon/5369" target="_self">download it from</a> here and <a href="http://developer.yahoo.com/performance/rules.html" target="_self">read the performance criteria here</a>.</p>
<p style="text-align: left;">
<h3>Bonus:  Colorzilla<strong> </strong></h3>
<p><strong>Home: </strong><a href="http://www.colorzilla.com/firefox/" target="_self">http://www.colorzilla.com/firefox/</a></p>
<p style="text-align: left;"><strong>Install: </strong><a href="https://addons.mozilla.org/en-US/firefox/addon/271" target="_self">https://addons.mozilla.org/en-US/firefox/addon/271</a></p>
<p style="text-align: left;">Need to pick a color from any web page, text or image within browser? Just click colorzilla, which sits at extreme left of your status bar, and point to that location. Now right click on colorzilla and you can copy rgb and hex color codes for that color.</p>
<p style="text-align: left;">It comes with a built in Color Picker and Palette Browser.</p>
<p style="text-align: left;">
<p style="text-align: left;">
<div class="shr-publisher-509"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F01%2F21%2F5-must-have-firefox-addons-for-every-web-developer%2F' data-shr_title='5+must+have+firefox+addons+for+every+web+developer'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/01/21/5-must-have-firefox-addons-for-every-web-developer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to dynamically load the Google Maps javascript API (On demand loading)</title>
		<link>http://www.vijayjoshi.org/2010/01/19/how-to-dynamically-load-the-google-maps-javascript-api-on-demand-loading/</link>
		<comments>http://www.vijayjoshi.org/2010/01/19/how-to-dynamically-load-the-google-maps-javascript-api-on-demand-loading/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 10:21:25 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[google map]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=481</guid>
		<description><![CDATA[
			
				
			
		
Normally google maps js api is loaded at the time of page load via a script tag with src set. If map is not so major feature of your application or you want to reduce page download time, you can defer loading the javascript load it when required.
This is a javascript pattern called On demand javascript.
Bottomline is: &#8220;JavaScript being pulled ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F01%2F19%2Fhow-to-dynamically-load-the-google-maps-javascript-api-on-demand-loading%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F01%2F19%2Fhow-to-dynamically-load-the-google-maps-javascript-api-on-demand-loading%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Normally google maps js api is loaded at the time of page load via a script tag with src set. If map is not so major feature of your application or you want to reduce page download time, you can defer loading the javascript load it when required.<br />
This is a javascript pattern called <a title="On demand javascript" href="http://ajaxpatterns.org/On-Demand_Javascript" target="_self">On demand javascript</a>.</p>
<p>Bottomline is: <a title="On demand javascript summary" href="http://ajaxpatterns.org/On-Demand_Javascript#In_A_Blink" target="_self">&#8220;JavaScript being pulled from the server after the page has loaded</a>&#8220;.</p>
<p>Google maps provide the facility to dynamically load the api when required.  So no need to load it at the time of page load. I will present an example here which will load the maps api on click of a button. Here is how to do it.</p>
<div class="mceTemp">
<dl id="attachment_453" class="wp-caption alignnone" style="width: 190px;">
<dt class="wp-caption-dt"><a title="Google maps ondemand loading demo" href="http://www.vijayjoshi.org/examples/gmap.html" target="_blank"><img class="size-full wp-image-453" style="border:0px" title="demo" src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" width="180" height="45" /></a></dt>
</dl>
</div>
<p>As said above, <strong>DO NOT </strong>load any javascript api from Google using script tags. Instead we will use a button.</p>
<pre class="brush:html">
<input id="loadButton" onclick="loadAPI();" type="button" value="Load maps api" /></pre>
<p>To load the api onclick of this button, create a script tag, set its src and append it to document. This will load the Google AJAX API required to load other google APIs.</p>
<pre class="brush:js">function loadAPI()
{
    var script = document.createElement("script");
    script.src = "http://www.google.com/jsapi?key=YOUR_API_KEY_HERE&amp;callback=loadMaps";
    script.type = "text/javascript";
    document.getElementsByTagName("head")[0].appendChild(script);
}</pre>
<p>Do not forget to replace the API key above with your API key. (You can get an API key by <a title="Google maps API key" href="http://code.google.com/apis/maps/signup.html" target="_self">signing up here</a>)</p>
<p><strong>Important:</strong> Note the <strong>callback=loadMaps</strong> in script.src. This is the thing doing all the magic. It tells which function to call when AJAX API has loaded. In above case it will call loadMaps function. So, let us define that.</p>
<pre class="brush:js">function loadMaps()
{
    //AJAX API is loaded successfully. Now lets load the maps api
    google.load("maps", "2", {"callback" : mapLoaded});
}</pre>
<p>loadMaps function uses load method of google AJAX API to load a specific api. Above we loaded &#8220;maps&#8221; version &#8220;2&#8243;. Again callback is the name of function that will be called when maps api is loaded. callback function will be called only when the maps api is loaded successfully.</p>
<pre class="brush:js">function mapLoaded()
{
    //here you can be sure that maps api has loaded
    //and you can now proceed to render the map on page
    if (GBrowserIsCompatible())
    {
        var map = new GMap2(document.getElementById("map_canvas"));
        map.setMapType(G_SATELLITE_MAP);
        map.setCenter(new GLatLng(28.631466106808542, 77.07853317260742), 5);
    }
}</pre>
<p>That is all to it. I have created a demo along these lines. View source for code. <a title="Google maps ondemand loading demo" href="http://www.vijayjoshi.org/examples/gmap.html" target="_blank"><strong>You can see it here</strong></a>.</p>
<div class="shr-publisher-481"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2010%2F01%2F19%2Fhow-to-dynamically-load-the-google-maps-javascript-api-on-demand-loading%2F' data-shr_title='How+to+dynamically+load+the+Google+Maps+javascript+API+%28On+demand+loading%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2010/01/19/how-to-dynamically-load-the-google-maps-javascript-api-on-demand-loading/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Getting and setting value of html elements using jQuery</title>
		<link>http://www.vijayjoshi.org/2009/12/09/getting-and-setting-value-of-html-elements-using-jquery/</link>
		<comments>http://www.vijayjoshi.org/2009/12/09/getting-and-setting-value-of-html-elements-using-jquery/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 05:48:16 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=446</guid>
		<description><![CDATA[
			
				
			
		
If you have started using jQuery recently and you  are used to DOM methods of getting and setting values for form and html elements, this article is for you.
Using jQuery can be confusing in the beginning but it is a lot easier once you get hold of it. In this post I will summarize methods for getting and setting values ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F12%2F09%2Fgetting-and-setting-value-of-html-elements-using-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F12%2F09%2Fgetting-and-setting-value-of-html-elements-using-jquery%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>If you have started using jQuery recently and you  are used to DOM methods of getting and setting values for form and html elements, this article is for you.</p>
<p>Using jQuery can be confusing in the beginning but it is a lot easier once you get hold of it. In this post I will summarize methods for getting and setting values for html elements using jQuery. I assume that you are familiar with the $ function. Though it can be used in different ways to select elements, we will stick to selecting elements by id for the purpose of this tutorial.</p>
<p><a href="http://www.vijayjoshi.org/examples/jQuery.html"><img src="http://www.vijayjoshi.org/wp-content/uploads/demo.png" alt="View Demo" style="border:0px"/></a></p>
<p>An element can be accessed using its id as follows:</p>
<pre class="brush:js">$('#someId')</pre>
<h3>Textbox, Hidden field and Textarea</h3>
<p>All these elements share a common method. val() method is used to get and set values for these elements.</p>
<p>Setting:</p>
<pre class="brush:js">$('#someid').val('any value')</pre>
<p>will set the value of textbox to &#8220;any value&#8221;.</p>
<p>Getting:</p>
<pre class="brush:js">$('#someid').val()</pre>
<p>will get the value of that text box.</p>
<h3>Radio Buttons and checkboxes</h3>
<p>attr() is used to check/uncheck and select/unselect radios and checkboxes</p>
<p>Setting:</p>
<pre class="brush:js">$('#id').attr('checked', true)</pre>
<p>will select the control</p>
<pre class="brush:js">$('#id').attr('checked', false)</pre>
<p>will unselect the control</p>
<p>Getting</p>
<pre class="brush:js">$('#id').attr('checked')</pre>
<p>This will give true if radio/checkbox is checked/selected, false otherwise.</p>
<h3>Select box/ Combo box</h3>
<p>A notorious control, jQuery makes it very easy to get and set value of a combo box.</p>
<p>Setting:</p>
<pre class="brush:js">$('#selectbox').val('1')</pre>
<p>Pass the value of option that you wish to select to val()</p>
<p>Getting:</p>
<pre class="brush:js">$('#selectbox').val()</pre>
<p>This will give value of currently selected option in combo box</p>
<h3>Setting/Getting innerHTML  of other elements</h3>
<p>Just like innerHTML, jQuery provides a handy function to manipulate innerHTML for all html elements.</p>
<p>Setting:</p>
<pre class="brush:js">$('#somediv').html('some html inside a paragraph')</pre>
<p>This will set the innerHTML of element with id somediv</p>
<p>Getting:</p>
<pre class="brush:js">$('#somediv').html()</pre>
<p>This will return the innerHTML of an element.</p>
<p>Thats all to it. Again, a demo can be found at <a title="View Demo" href="http://www.vijayjoshi.org/examples/jQuery.html">this link</a> (and obviously source code too). You can always shoot me a mail in case your question is not answered here.</p>
<p><em>Give this article a thumbs up on stumble upon if you liked this</em></p>
<div class="shr-publisher-446"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F12%2F09%2Fgetting-and-setting-value-of-html-elements-using-jquery%2F' data-shr_title='Getting+and+setting+value+of+html+elements+using+jQuery'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2009/12/09/getting-and-setting-value-of-html-elements-using-jquery/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Collection of 10 top 10 lists about web development</title>
		<link>http://www.vijayjoshi.org/2009/09/23/collection-of-10-top-10-lists-about-web-development/</link>
		<comments>http://www.vijayjoshi.org/2009/09/23/collection-of-10-top-10-lists-about-web-development/#comments</comments>
		<pubDate>Wed, 23 Sep 2009 13:02:25 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[firefox]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=401</guid>
		<description><![CDATA[
			
				
			
		
I am a regular reader of web development articles and in this process bookmark a lot of them. Out of that collection I present to you a list of 10 articles which themselves are lists of 10(tips, functions etc). Not all of them are top 10   but equally good. All these articles are related to php, javascript, html, ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F09%2F23%2Fcollection-of-10-top-10-lists-about-web-development%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F09%2F23%2Fcollection-of-10-top-10-lists-about-web-development%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>I am a regular reader of web development articles and in this process bookmark a lot of them. Out of that collection I present to you a list of 10 articles which themselves are lists of 10(tips, functions etc). Not all of them are top 10 <img src='http://www.vijayjoshi.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  but equally good. All these articles are related to php, javascript, html, mysql and web development in general.</p>
<h3><a title="10 code snippets for PHP developers" href="http://htmlblog.net/10-code-snippets-for-php-developers/" target="_self">1-  10 code snippets for PHP developers</a></h3>
<p>Simple and handy functions for common tasks like validating email address and XSL transformation.</p>
<p>&nbsp;</p>
<h3><a title="10 Advanced PHP Tips Revisited" href="http://www.smashingmagazine.com/2009/03/24/10-useful-php-tips-revisited/" target="_self">2- 10 Advanced PHP Tips Revisited</a></h3>
<p>Detailed and excellent tips from famous PHP gurus Chris Shiflett and Sean Coates.</p>
<p>&nbsp;</p>
<h3><a title="Top 10 PHP frameworks" href="http://www.phpframeworks.com/top-10-php-frameworks/" target="_self">3- Top 10 PHP frameworks</a></h3>
<p>PHP frameworks are quite popular among developers these days. This site is dedicated to php frameworks alone. In this article all frameworks have been compared for features. Very useful to help you in decision making if you are planning to use a framework for your next project.</p>
<p>&nbsp;</p>
<h3><a title="Top 10 custom JavaScript functions" href="http://www.dustindiaz.com/top-ten-javascript/" target="_self">4- Top 10 custom JavaScript functions of all time</a></h3>
<p>This is my favorite one. These 10 functions are a must in every web developer&#8217;s toolbox. Functions like getElementsByClass, toggle and cookie functions are included.</p>
<p>&nbsp;</p>
<h3><a title="JavaScript Tips and Best Practices" href="http://www.impressivewebs.com/10-javascript-quick-tips-and-best-practices/" target="_self">5- 10 JavaScript Quick Tips and Best Practices</a></h3>
<p>Another good article on javascript best practices.</p>
<p>&nbsp;</p>
<h3><a title="Top 10 Firefox Addons For Web Developers" href="http://www.hurricanesoftwares.com/top-10-firefox-addons-for-web-developers/" target="_self">6- Top 10 Firefox Addons For Web Developers</a></h3>
<p>Who hasn&#8217;t heard of Firebug or GreaseMonkey. This article lists similar addons for firefox that are a great help in web development.</p>
<p>&nbsp;</p>
<p><span id="more-401"></span></p>
<h3><a title="10 Ways to Improve Your Web Page Performance" href="http://sixrevisions.com/web-development/10-ways-to-improve-your-web-page-performance/" target="_blank">7- 10 Ways to Improve Your Web Page Performance</a></h3>
<p>From the article:</p>
<blockquote><p>
This article primarily focuses on front-end performance since it’s the easiest to work on and provides you the most bang for your buck.</p></blockquote>
<p>&nbsp;</p>
<h3><a title="Web Development Tricks" href="http://zygote.egg-co.com/10-dirty-little-web-development-tricks/" target="_self">8- 10 Dirty Little Web Development Tricks</a></h3>
<p>Simple tips to help you in web development.</p>
<p>&nbsp;</p>
<h3><a title="10 Rare HTML Tags You Really Should Know" href="http://net.tutsplus.com/articles/web-roundups/10-rare-html-tags-you-really-should-know/" target="_self">9- 10 Rare HTML Tags You Really Should Know</a></h3>
<p>List of 10 html tags that are not used frequently. Check them out. It is possible that you have not heard about some of them.</p>
<p>&nbsp;</p>
<h3><a title="10 Useful articles about Database design" href="http://woork.blogspot.com/2008/09/10-useful-articles-about-database.html" target="_self">10- 10 Useful articles about Database design</a></h3>
<p>From the article:</p>
<blockquote><p>
The list includes some tips to define relationships-entities model, common database design mistakes, database normalization, how to use PHP and SQL to create tables and relationships and a correct approach to define relationships between tables.</p></blockquote>
<div class="shr-publisher-401"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F09%2F23%2Fcollection-of-10-top-10-lists-about-web-development%2F' data-shr_title='Collection+of+10+top+10+lists+about+web+development'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2009/09/23/collection-of-10-top-10-lists-about-web-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>javascript : 7 tips for better coding</title>
		<link>http://www.vijayjoshi.org/2009/09/11/javascript-7-tips-for-better-coding/</link>
		<comments>http://www.vijayjoshi.org/2009/09/11/javascript-7-tips-for-better-coding/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 07:35:17 +0000</pubDate>
		<dc:creator>Vijay Joshi</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.vijayjoshi.org/?p=375</guid>
		<description><![CDATA[
			
				
			
		
1- Use short hand notation for declaring arrays and objects
Arrays and objects are declared as following:
var someArray = new Array();
var someObject = new Object();
There is a shorthand notation for declaring these which is much more easier to use. It can be used like this:
var someArray = [];
var someObject = {};
2- Use square bracket notation &#8211; [] &#8211; to access property ...]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop --><!-- End Shareaholic LikeButtonSetTop --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F09%2F11%2Fjavascript-7-tips-for-better-coding%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F09%2F11%2Fjavascript-7-tips-for-better-coding%2F&amp;source=v08i&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<h3>1- Use short hand notation for declaring arrays and objects</h3>
<p>Arrays and objects are declared as following:</p>
<pre class="brush:js">var someArray = new Array();
var someObject = new Object();</pre>
<p>There is a shorthand notation for declaring these which is much more easier to use. It can be used like this:</p>
<pre class="brush:js">var someArray = [];
var someObject = {};</pre>
<h3>2- Use square bracket notation &#8211; [] &#8211; to access property of an object rather then using . (dot) notation</h3>
<p>There is a good reason why you should do this. Suppose you have an object like following:</p>
<pre class="brush:js">var myObject = { "name1" : "some name" , "name2" : "another name" , "name3" : "yet another name" };</pre>
<p>Properties of myObject can be accessed using either of the 2 ways.</p>
<pre class="brush:js">var value = myObject["name2"]; // will output another name
var value = myObject.name2; // will output another name</pre>
<p>Now assume you want to access these values dynamically (probably in a loop). Now see what happens.</p>
<pre class="brush:js">var result = myObject.name + i; //this is an error

var result = myObject['name' + i]; // this is good. will output correct value depending on value of i</pre>
<p>If you take the first approach, you are in a mess. It will look for myObject.name and will try to add the value of i to it and thus an error<br />
Using the second method is safer and readable too.</p>
<h3>3-    Break a long string into multiple lines</h3>
<p>This surely makes code more readable. You can do it like below.</p>
<pre class="brush:js">var longStr = "This is a long long "
+ "string which has been "
+ "broken into "
+ "multiple lines.";</pre>
<p>Think there is only one way of doing so? No, Here is another(lesser known) method:</p>
<pre class="brush:js">var longStr = "This is a long long \
string which has been \
broken into \
multiple lines.";</pre>
<p><span id="more-375"></span></p>
<h3>4-    Specify radix while using parseint (always)</h3>
<p>Just try this.</p>
<pre class="brush:js">var result = parseInt("012"); // gives 10</pre>
<p>Baffled!!! You expected 12 but got 10. Solution? Always specify the second parameter(radix) while using parseInt. By default parseInt considers strings starting from 0 as octal numbers. So unless you want an octal or hexadecimal just pass 10 as second parameter to parseInt. <a title="javascript parseint" href="http://www.vijayjoshi.org/2009/01/07/faq-problem-with-javascript-function-parseint/" target="_self">Read more details about this behavior on this post</a>.</p>
<h3>5- innerHTML is faster than w3c DOM methods</h3>
<p>There are 2 ways you can alter content of any html element from javascript. innerHTML property or w3c DOM methods. Wherever possible user innerHTML because it is faster than DOM methods. Quirksmode.org has a test which measures the execution times of various methods in different browsers (<a title="innerhtml vs w3c dom" href="http://www.quirksmode.org/dom/innerhtml.html" target="_self">http://www.quirksmode.org/dom/innerhtml.html</a>). All results show that innerHTML is fastest.</p>
<h3>6- Setting innerHTML does not always work (in IE specifically)</h3>
<p>Yes, that&#8217;s right. Manipulating the DOM from javascript is a common practice.</p>
<pre class="brush:js">document.getElementById(id).innerHTML = 'some html';</pre>
<p>However, the above does not work in IE for some elements. Don&#8217;t know why MS did it. (<a title="IE innerhtml bug" href="http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx" target="_self">Read what MSDN says</a>). The elements for which innerHTML can&#8217;t be set are col, colgroup, frameset, head, html, style, table, tbody, tfoot, theaf, title, tr. Trying to set innerHTML for these elements will fail. Instead, use DOM methods for these elements.<br />
Also, setting innerHTML of select box cannot be relied upon  in IE (<a title="IE innerhtml bug" href="http://www.vijayjoshi.org/2008/10/05/setting-innerhtml-of-select-ie-screws-me-again/" target="_self">Read full article here</a>).<br />
It displays some weird behavior. Avoid innerHTML for select too. As said above, use DOM methods in this case.</p>
<h3>7- Always count large arrays before iterations</h3>
<p>0k. This is not particular to javascript but applies to all languages. Consider an array of 10,000 items.<br />
Normally, a for loop will go like following:</p>
<pre class="brush:js">var largeArray; // // this array has 10,000 items
for( var i=0; i < largeArray.length; i++)
{
    //do something
}</pre>
<p>In above case javascript has to calculate length of array in each iteration and then check the termination condition. It will be far more efficient if we calculate length of array before loop, store it in a local variable and use this local variable for comparison.</p>
<pre class="brush:js">var largeArray; // this array has 10,000 items
var l = largeArray.length;
for( var i=0; i < l; i++)
{
    //do something
}</pre>
<p>This will save javascript from calculating the array length in each iteration and will be faster.</p>
<div class="shr-publisher-375"></div><!-- Start Shareaholic LikeButtonSetBottom --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:right;height:30px;'><a class='shareaholic-googleplusone' data-shr_size='medium' data-shr_count='true' data-shr_href='http%3A%2F%2Fwww.vijayjoshi.org%2F2009%2F09%2F11%2Fjavascript-7-tips-for-better-coding%2F' data-shr_title='javascript+%3A+7+tips+for+better+coding'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom -->]]></content:encoded>
			<wfw:commentRss>http://www.vijayjoshi.org/2009/09/11/javascript-7-tips-for-better-coding/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

