<?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>Dev Tips &#124; Become a Better Developer, One Tip at a Time. &#187; jQuery</title>
	<atom:link href="http://dev-tips.com/category/client-side/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://dev-tips.com</link>
	<description>Become a Better Developer, One Tip at a Time.</description>
	<lastBuildDate>Sun, 07 Mar 2010 02:19:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Awesome radio button grouping with jQuery</title>
		<link>http://dev-tips.com/featured/awesome-radio-button-grouping-with-jquery</link>
		<comments>http://dev-tips.com/featured/awesome-radio-button-grouping-with-jquery#comments</comments>
		<pubDate>Sun, 20 Dec 2009 02:21:13 +0000</pubDate>
		<dc:creator>Barry Roodt</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[grouping]]></category>
		<category><![CDATA[radio]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=679</guid>
		<description><![CDATA[I was asked to do something rather interesting with some radio button inputs the other day. I haven't come across this particular problem before and google didn't return anything helpful, so I decided to share what I came up with. Live Demo First, the scenario We have a standard form with 4 radio button groups. [...]]]></description>
			<content:encoded><![CDATA[<p>I was asked to do something rather interesting with some radio button inputs the other day. I haven't come across this particular problem before and google didn't return anything helpful, so I decided to share what I came up with.</p>
<p><span id="more-679"></span></p>
<h2 class='box demo'><a target='_blank' href='http://flexidev.co.za/dev/code/advancedradio/' title='View Demo'>Live Demo</a></h2>
<h2>First, the scenario</h2>
<p>We have a standard form with 4 radio button groups. Each group has 4 radio buttons labeled from<em> "1" </em>to <em>"4"</em>. Now, when the user selects<em> "option 1"</em> in <em>"group 1"</em>, all the remaining <em>"option 1"</em> items need to be disabled. To see an example in action, <a title="Advanced Radio demo" href="http://flexidev.co.za/dev/code/advancedradio/" target="_blank">you can view the demo here</a>.</p>
<h2>The problem</h2>
<p>When I first started, I thought that it's simply a matter of giving each <em>"option"</em> (regardless of group) a common class name - then just disabling all other options with the same class name. That works, to a point, but what if the user changes his mind and selects another option ? Now I had to find all previously disabled options, re-enable them and start all over again.</p>
<h2>The solution</h2>
<p>Essentially what I came up with was a basic nested loop to handle setting and unsetting the relevant <em>"disabled"</em> attributes. To achieve this, first we assign all <em>"option 1"</em> a class of <em>"number1"</em>, <em>"option 2"</em> a class of <em>"number2"</em> and so on.</p>
<p>Next, we run a basic <strong><em>for loop</em></strong>, and go through each <em>"number"</em> class (i.e. number1 to number4). For each class, we call a function. Inside this function is another loop - this time iterating over each radio button assigned the current class name. Using this loop, we remove any <em>"disabled" </em>attributes which may have been assigned previously.</p>
<p>We also find out which item in that group is currently selected (if any) - this is so we can run a second loop to disable all those options not currently selected. Confused ? Now might be a good time to go through the code.</p>
<h2>The code</h2>
<pre class="brush: js">
$(function(){
		// fire our code when a radio button has been selected
		$(&quot;input[type=radio]&quot;).change(function(){
			var name = $(this).attr(&quot;name&quot;); // get the current button&#039;s group name
			$(&quot;input[name=&quot;+name+&quot;]&quot;).removeAttr(&quot;selected&quot;); // first we deselect &quot;all&quot; radio buttons within the same group
			$(this).attr(&quot;selected&quot;,&quot;selected&quot;); // make sure our currently &quot;changed&quot; button is selected
			for(i=1;i&lt;=4;i++){ // go through the 4 radio classes
				processRadio(&quot;.radio&quot;+i);
			}
		});
		/**
			Loops through each item with same &quot;class&quot; name and disables/enables where appropriate
		**/
		function processRadio(myclass){
			var empty;
			var id = &quot;&quot;;
			var buttons = $(myclass); // read all buttons with the specified class name into a jQuery object
			buttons.each(function(){ // loop through each item
				var me = $(this);
				var isSelected = me.attr(&quot;selected&quot;); // bool value, based on whether the &quot;selected&quot; attribute is present or not
				me.removeAttr(&quot;disabled&quot;); // clear the disabled attribute if present
				me.siblings(&quot;label&quot;).removeClass(&quot;disabled&quot;); // same with the associated label element
				if (isSelected != empty &amp;amp;&amp;amp; isSelected != &quot;&quot;){
					id = $(this).attr(&quot;id&quot;); // set our tmp id var to our currently selected item
				}
			});
			// make sure we have an id, otherwise we&#039;ll get an error
			if (id != empty &amp;amp;&amp;amp; id != &quot;&quot;){
				buttons.each(function(){ // loop through each radio button once again
					if ($(this).attr(&quot;id&quot;) != id){ // set the disabled attributes if id attribute doesn&#039;t match our tmp id var
						$(this).attr(&quot;disabled&quot;, &quot;disabled&quot;).siblings(&quot;label&quot;).addClass(&quot;disabled&quot;);
					}
				});
			}
		}

	});
</pre>
<p>I&#39;ve commented as best I could, which hopefully makes more sense than my rambling above. Once again, there is a <a title="Advanced Radio demo" href="http://flexidev.co.za/dev/code/advancedradio/" target="_blank">working demo available</a> for you to play with. Be sure to have a look at the markup as well, might clear up a few questions.</p>
<p>I strongly suspect that there's a more efficient method for achieving the same result - so if you have a better suggestion, tweak or link please let me know - I'd greatly appreciate it.</p>
<h2 class='box demo'><a href='http://flexidev.co.za/dev/code/advancedradio/' title='View Demo'>Live Demo</a></h2>
<h2>Editors Note - PHP Book Giveaway</h2>
<p>I'll be announcing the winner for the <a><em>PHP For Absolute Beginners</em> book giveaway</a> on monday, so now is your last second chance to get your comment in for a chance to win. <a href='http://dev-tips.com/featured/php-for-absolute-beginners-reviewed-giveaway'>See here for more details and to enter.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/awesome-radio-button-grouping-with-jquery/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Link Nudge jQuery Plugin</title>
		<link>http://dev-tips.com/featured/link-nudge-jquery-plugin</link>
		<comments>http://dev-tips.com/featured/link-nudge-jquery-plugin#comments</comments>
		<pubDate>Wed, 05 Aug 2009 21:06:02 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=499</guid>
		<description><![CDATA[I think it was David Walsh who first showed me the idea of link nudging using jQuery. You can see on the sidebar we also use this technique. I haven't seen a plugin made to do this yet (as it is really simple) so I figured this would be perfect for a quick jQuery plugin [...]]]></description>
			<content:encoded><![CDATA[<p>I think it was <a href='http://davidwalsh.name/jquery-link-nudging'>David Walsh who first showed me</a> the idea of link nudging using jQuery. You can see on the sidebar we also use this technique. I haven't seen a plugin made to do this yet (as it is really simple) so I figured this would be perfect for a quick jQuery plugin tutorial. You can download the plugin and/or view the demo below.</p>
<p><span id="more-499"></span></p>
<h2 class='box demo'><a href='http://dev-tips.com/demo/link_nudge.html' title='Link Nudge Demo'>View Demo</a></h2>
<div class='download_orange'><a class="downloadlink" href="http://dev-tips.com/wp-content/plugins/download-monitor/download.php?id=3" title="Version 1.0 downloaded 527 times" >jQuery Link Nudge Plugin (527) - 19.9 KB</a></div>
<p><strong>Authors Note:</strong><em>This plugin has now been given the name of NudgeIt and has had a lot of new features added! Please see the two updates at the bottom of this page for more information.</em></p>
<h2>The Plugin Javascript</h2>
<p>Creating the plugin is simple and is as easy as creating any other jQuery plugin. I'll try to comment the source code some so you can get an idea of how it all works.</p>
<p></p><p><strong><a href='http://snipplr.com/view/17929/jquery-link-nudge-plugin'>jQuery Link Nudge Plugin</a></strong><br/><small>Posted by <a href='http://snipplr.com/users/DrewDouglass'>DrewDouglass</a> on August 5th, 2009</small><br/><small>Plugin Source.</small></p><div class='code' style='border: 1px dotted; overflow: auto; white-space:nowrap;'><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>$<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Define the plugin, named 'linkNudge' </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #006600;">fn</span>.<span style="color: #006600;">linkNudge</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>params<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//set default parameters </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; params = $.<span style="color: #006600;">extend</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; padding: <span style="color: #CC0000;">20</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; elapseTime: <span style="color: #CC0000;">300</span>, <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; returnPadding: <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#125;</span>, params<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Traverse every node passed </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Define this as a single object </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> $t = $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Proceed to nudge on hover </span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t.<span style="color: #006600;">hover</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t.<span style="color: #000066;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">css</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'cursor'</span>, <span style="color: #3366CC;">'pointer'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">animate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>paddingLeft: params.<span style="color: #006600;">padding</span><span style="color: #66cc66;">&#125;</span>, params.<span style="color: #006600;">elapseTime</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $t.<span style="color: #000066;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">animate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>paddingLeft: params.<span style="color: #006600;">returnPadding</span><span style="color: #66cc66;">&#125;</span>, params.<span style="color: #006600;">elapseTime</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>;<span style="color: #009900; font-style: italic;">//Allow for chaining.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span>jQuery<span style="color: #66cc66;">&#41;</span>;</div><p></p>
<h2>Usage</h2>
<pre class="brush: js">
$(function(){
		$(&#039;ul li:even&#039;).linkNudge({
			elapseTime: 500
		}).css(&#039;list-style-type&#039;, &#039;circle&#039;);//Plugin allows for chaining, as seen with the css call.
	});
</pre>
<h2>Documentation</h2>
<p>To use the plugin, simply include the plugin and jQuery library on your page and make a call to the <code>linkNudge</code> function. You can include three optional parameters, as discussed below.</p>
<ol>
<li><strong>padding</strong> - Allows you to set how far the link should be nudged. Defaults to 20px.</li>
<li><strong>elapseTime</strong> - The time, in milliseconds, over which the nudge should occur. Default to 300.</li>
<li><strong>returnPadding</strong> - Optional padding to return to when the element is no longer being hovered. Defaults to 0.</li>
<h2>Terms of Use</h2>
<p>You can't sell it. Otherwise, use it how you would like in your projects, a credit to this page in the notes or documentation would be appreciated. Donations even more so.</p>
<h2 class='box demo'><a href='http://dev-tips.com/demo/link_nudge.html' title='Link Nudge Demo'>View Demo</a></h2>
<div class='download_orange'><a class="downloadlink" href="http://dev-tips.com/wp-content/plugins/download-monitor/download.php?id=3" title="Version 1.0 downloaded 527 times" >jQuery Link Nudge Plugin (527) - 19.9 KB</a></div>
<h2>Feed Me</h2>
<p>If you have used or enjoy this plugin, I urge you to consider making a small donation so I can buy some Chinese food.</p>
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="7298669">
<input type="image" src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1"><br />
</form>
<h2><strong>Update:</strong></h2>
<p>David Walsh has modified the flexibility of the plugin in a <a href='http://davidwalsh.name/jquery-link-nudge'>new post on his blog</a>. I encourage all of you to give it a look and download and see how they differ. You can find <a href='http://davidwalsh.name/jquery-link-nudge'>Davids plugin on his website</a>. Thanks for adding on to and improving the plugin David!</p>
<h2><strong>Update Two!</strong></h2>
<p>David and I have decided to collaborate on this plugin and host it on a <a href='http://github.com/DrewDouglass/NudgeIt'>GitHub</a> so everyone can easily keep track of any updates or changes. We are now also calling the plugin, quite appropriately, <strong>NudgeIt</strong>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/link-nudge-jquery-plugin/feed</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>CSS Tip: How to Make Circles Without Images</title>
		<link>http://dev-tips.com/featured/css-tip-how-to-make-ircles-without-images</link>
		<comments>http://dev-tips.com/featured/css-tip-how-to-make-ircles-without-images#comments</comments>
		<pubDate>Mon, 04 May 2009 02:53:28 +0000</pubDate>
		<dc:creator>Vasili</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=403</guid>
		<description><![CDATA[About a month ago, Jeffery Way posted an article about creating shapes with pure CSS, no images added. I've been using the CSS3 property of border radius a lot in a design I've been working on and thought, "why can't I use this to make circles?" Today, I'll show you how to make your very [...]]]></description>
			<content:encoded><![CDATA[<p>About a month ago, <a href="http://net.tutsplus.com/videos/screencasts/fun-with-css-shapes/">Jeffery Way</a> posted an article about creating shapes with pure CSS, no images added. I've been using the CSS3 property of border radius a lot in a design I've been working on and thought, "why can't I use this to make circles?" Today, I'll show you how to make your very own CSS circles. In addition, we will use our new knowledge to create a simple jQuery plugin!</p>
<p><span id="more-403"></span></p>
<h2 class='box demo'><a href='http://dev-tips.com/demo/css3_circles.html' title='CSS 3 Circles Demo' target='_blank'>View Demo</a></h2>
<h3>Structure, structure, structure!</h3>
<p>How are we suppose to make a circle without any HTML to style? Because this is just a simple shape, I'll be using an "empty" span tab — I've just put &amp;nbsp; into it.</p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;

&lt;title&gt;CSS Circle&lt;/title&gt;
&lt;style type=&quot;text/css&quot;&gt;
* {
margin: 0;
padding: 0;
}
body {
margin: 1in;
}
.circle {
/* Everything else goes here. */
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;span class=&quot;circle&quot;&gt;&amp;amp;amp;nbsp;&lt;/span&gt;

&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>I'll be using inline CSS because this is just a demo, but if this were for a project you'd probably want to put it in an external style sheet. I've also reset the margins and padding, then gave the body a one inch margin to push our circle away from the sides of the page.</p>
<h3>Basic Styles</h3>
<p>For now, I'll give the circle a background of #333 just so we can see it. You'll also want to give it the same height and width, this is the length of the diameter. The size doesn't really matter just make sure it's <strong>en even number</strong>.</p>
<pre class="brush: css">
.circle {
display: block;
width: 80px;
height: 80px;
background: #333;
}
</pre>
<p><em>Note: If you're using an inline element (like a span tag), you'll want to give the element a display of "block". If you don't know if your element is a block level element or not, just load the file in a web browser and if it's height and width look larger than 1px it is.</em></p>
<h3>Circles Are Really Made With CSS3</h3>
<p>What really gives this circle its arcs is CSS3's <a href="http://www.css3.info/preview/rounded-border/">-moz-border-radius and -webkit-border-radius</a> properties. What we're going to have to do is give the border radius a value of <strong>half the height/width</strong>; this is the radius of the circle. For my example, I've used 80px for the height and width so I'll set the border radius to 40px.</p>
<pre class="brush: css">
.circle {
display: block;
display: block;
width: 80px;
height: 80px;
background: #333;
-moz-border-radius: 40px;
-webkit-border-radius: 40px;
}
</pre>
<h3>Conclusion</h3>
<p>CSS3 is a very powerful tool to know how to use. Just make sure you don't base your entire website around it because not every browser supports it yet. However, if you can get the effect in certain browsers and still have you're design looking okay in other browsers, I think it's fine to use browser specific styles.</p>
<h3>Create a jQuery Plugin For Our Circles</h3>
<p>You can also take this a step further by making it into a jQuery plugin.</p>
<pre class="brush: js">
(function($){

	$.fn.jCircle = function(options) {
		var defaults = {
			size: 40
		},
			settings = $.extend({}, defaults, options);

		settings.size = parseInt(settings.size) || 40;
		settings.radius = (settings.size/2) + &#039;px&#039;;

		return this.each(function(){
			var $this = $(this);

			$this.css({
				display: &#039;block&#039;,
				width: settings.size + &#039;px&#039;,
				height: settings.size + &#039;px&#039;
			});

			$this.css(&#039;-moz-border-radius&#039;, settings.radius);
			$this.css(&#039;-webkit-border-radius&#039;, settings.radius);
		});
	}

})(jQuery);
</pre>
<h2 class='box demo'><a href='http://dev-tips.com/demo/css3_circles.html' title='CSS 3 Circles Demo' target='_blank'>View Demo</a></h2>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/css-tip-how-to-make-ircles-without-images/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Javascript Tip: Easy Fading Using jQuery</title>
		<link>http://dev-tips.com/featured/javascript-tip-easy-fading-using-jquery</link>
		<comments>http://dev-tips.com/featured/javascript-tip-easy-fading-using-jquery#comments</comments>
		<pubDate>Thu, 30 Apr 2009 22:29:49 +0000</pubDate>
		<dc:creator>John Bloomfield</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[HTML/CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=365</guid>
		<description><![CDATA[Whilst working on a project recently I came across a need for us to show a selection of images depending on their type and when a link to them is clicked. I decided to use jQuery as it saves a lot of time as most of the work is done for you. I will step [...]]]></description>
			<content:encoded><![CDATA[<p>Whilst working on a project recently I came across a need for us to show a selection of images depending on their type and when a link to them is clicked. I decided to use jQuery as it saves a lot of time as most of the work is done for you. I will step through the code so you can see how I did it.
</p>
<p><span id="more-365"></span></p>
<h3><a href='http://dev-tips.com/demo/fading/' target='_blank'>View Demo</a></h3>
<p>As with any jQuery, we are required to use the following line to tell our jQuery code to run as soon as DOM is ready rather than when the page has finished loading.</p>
<pre class="brush: js">
$(document).ready(function(){
</pre>
<p>The next line detects any click from a link inside the div with an id of “links”</p>
<pre class="brush: js">$(&#039;#links a&#039;).click(function(){</pre>
<p>Once a link has been clicked any attribute from that link is accessible through $(this), so the next line sets up a new variable called “color” and takes the “rel” attribute from the tag and puts it into our new variable.</p>
<pre class="brush: js">var color = $(this).attr(&#039;rel&#039;);</pre>
<p>Once we know which colour link has been clicked we can then fade out all images that have a different colour and fade in the colour that has been clicked.</p>
<pre class="brush: js">
$(&#039;#tiles div.tile:not(.&#039; + color + &#039;) img&#039;).fadeTo(&quot;slow&quot;, 0.3);
$(&#039;#tiles div.&#039; + color + &#039; img&#039;).fadeTo(&quot;slow&quot;, 1);
</pre>
<p>To finish off we need to close our function brackets. You will notice there is a “return false;”. This is to stop the link actually activating the href attribute and basically overriding it so we can do our magic. This becomes useful when users don’t have Javascript activated in there browser, you can make the link work as normal. Unfortunately, you would need to create separate pages with different colours highlighted instead. (sigh!)</p>
<p>So, to sum up I have put all the code below and you will need to remember to include the latest jQuery Javascript file from <a href='http://jquery.com'>www.jquery.com</a><br />
All the HTML you can grab from the source of the demo page.</p>
<h2>Final Code</h2>
<pre class="brush: js">
$(document).ready(function(){
   $(&#039;#links a&#039;).click(function(){
      var color = $(this).attr(&#039;rel&#039;);
      $(&#039;#tiles div.tile:not(.&#039; + color + &#039;) img&#039;).fadeTo(&quot;slow&quot;, 0.3);
      $(&#039;#tiles div.&#039; + color + &#039; img&#039;).fadeTo(&quot;slow&quot;, 1);
   });
   return false;
});
</pre>
<p>Hopefully, this will be useful to someone. Have fun!</p>
<h3><a href='http://dev-tips.com/demo/fading/' target='_blank'>View the Demo</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/javascript-tip-easy-fading-using-jquery/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to validate Date of Birth with jQuery</title>
		<link>http://dev-tips.com/featured/how-to-validate-date-of-birth-with-jquery</link>
		<comments>http://dev-tips.com/featured/how-to-validate-date-of-birth-with-jquery#comments</comments>
		<pubDate>Tue, 10 Mar 2009 00:38:13 +0000</pubDate>
		<dc:creator>Barry Roodt</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=261</guid>
		<description><![CDATA[In a recent project I had to implement what's commonly referred to as a Legal Drinking Age (LDA) page. Basically what needs to happen is that the user has to enter their date of birth and thus 'confirm' that they are of a legal drinking age for their respective country. You can view an example [...]]]></description>
			<content:encoded><![CDATA[<p>In a recent project I had to implement what's commonly referred to as a Legal Drinking Age (LDA) page. Basically what needs to happen is that the user has to enter their date of birth and thus 'confirm' that they are of a legal drinking age for their respective country. <a href="http://www.mgstreetdanceafrica.com" title="Malta Guinness Streetdance Africa">You can view an example of just such a page here</a>.</p>
<p>This brought me to an interesting requirement - the user needs to enter their birth of date (in this case via 3 select boxes), their age then needs to be calculated from the entered date and they are either granted, or denied access based on the result.</p>
<p><span id="more-261"></span></p>
<p>Interestingly enough, after having a quick look around I hadn't been able to find any similar example, so I had to come up with something myself. The following code is my solution:</p>
<pre class="brush: js">
$(&quot;#lda-form&quot;).submit(function(){
var day = $(&quot;#day&quot;).val();
var month = $(&quot;#month&quot;).val();
var year = $(&quot;#year&quot;).val();
var age = 18;

var mydate = new Date();
mydate.setFullYear(year, month-1, day);

var currdate = new Date();
currdate.setFullYear(currdate.getFullYear() - age);
if ((currdate - mydate) &lt; 0){
alert(&quot;Sorry, only persons over the age of &quot; + age + &quot; may enter this site&quot;);
return false;
}
return true;
});
</pre>
<p>First, we get the relevant entered date values - the <strong><em>"day"</em></strong>, <strong><em>"month"</em></strong> and <strong><em>"year"</em></strong>. I've also added an <strong><em>"age"</em></strong> var so that this can be easily edited if necessary - the current value is set to 18.</p>
<p>Next we create a Date object and call it <strong><em>"mydate"</em></strong>. We then use the object's <strong><em>"setFullYear"</em></strong> method to set the value of <strong><em>"mydate"</em></strong> to the user's entered birth date. <a title="Javascript setFullYear method" href="http://www.w3schools.com/jsref/jsref_setFullYear.asp">You can view more information about this method here</a>. The only thing to notice here is that we have subtract 1 from the <strong><em>"month"</em></strong> value as it's 0 indexed.</p>
<p>Now that we have the user's birth date sorted, we then create another Date object and call it <strong><em>"currdate"</em></strong>. The default value for <strong><em>"currdate"</em></strong> is the current date. We then set "currdate" to whatever the current date is minus our <strong><em>"age"</em></strong> value - i.e. Today - 18 years. Once again, we use the <strong><em>"setFullYear"</em></strong> method to set the date. However, to get the current date in a useable format, we use the <strong><em>"getFullYear"</em></strong> method and THEN subtract 18 from the resulting value. So to do this we use <strong><em>"currdate.getFullYear() - age"</em></strong>.</p>
<p>Once we have the date of 18 years ago and the user's birth date, both in the same format, it's simply a matter of making sure that the required date minus the birth date isn't greater than 0. If so, we output an alert to inform the user then return <strong><em>"false"</em></strong> to make sure that the form doesn't get submitted.</p>
<p>Pretty straightforward.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/how-to-validate-date-of-birth-with-jquery/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>jQuery Tip: Font Resizing With Animation Effects</title>
		<link>http://dev-tips.com/featured/jquery-tip-font-resizing-with-animation-effects</link>
		<comments>http://dev-tips.com/featured/jquery-tip-font-resizing-with-animation-effects#comments</comments>
		<pubDate>Fri, 16 Jan 2009 21:04:27 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=93</guid>
		<description><![CDATA[Hey everyone. Sorry for not having a new tip published yesterday, I was feeling under the weather. Seeing how popular the original font resizing with jQuery article was, I thought it would be nice to spice up our original script with a little animation. This is extremely easy to do with jQuerys built in animation [...]]]></description>
			<content:encoded><![CDATA[<p>Hey everyone. Sorry for not having a new tip published yesterday, I was feeling under the weather. Seeing how popular the <a href='http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing'>original font resizing with jQuery article</a> was, I thought it would be nice to spice up our original script with a little animation. This is extremely easy to do with jQuerys built in animation functions. </p>
<p><span id="more-93"></span></p>
<h3>The Original Script</h3>
<p><pre class="brush: javascript">
$(function(){
		$(&#039;input&#039;).click(function(){
			var ourText = $(&#039;p&#039;);
			var currFontSize = ourText.css(&#039;fontSize&#039;);
			var finalNum = parseFloat(currFontSize, 10);
			var stringEnding = currFontSize.slice(-2);
			if(this.id == &#039;large&#039;) {
				finalNum *= 1.2;
			}
			else if (this.id == &#039;small&#039;){
				finalNum /=1.2;
			}
			ourText.css(&#039;fontSize&#039;, finalNum + stringEnding);
		});
	});
</pre>
</p>
<h3>Achieving the Animation Effect</h3>
<p>Instead of instantly resizing the text upon click, we want the text to re size over a specified amount of milliseconds. We can still use our original script but we will replace the last section from the css() method to the animate() method. </p>
<h3>Our New Script</h3>
<p>Here is our new script complete with animation effects.</p>
<pre class="brush: javascript">
$(function(){
		$(&#039;input&#039;).click(function(){
			var ourText = $(&#039;p&#039;);
			var currFontSize = ourText.css(&#039;fontSize&#039;);
			var finalNum = parseFloat(currFontSize, 10);
			var stringEnding = currFontSize.slice(-2);
			if(this.id == &#039;large&#039;) {
				finalNum *= 1.2;
			}
			else if (this.id == &#039;small&#039;){
				finalNum /=1.2;
			}
			ourText.animate({fontSize: finalNum + stringEnding},600);
		});
	});
</pre>
<p>Quite simple isn't it? Get creative and add your own touch or animations to your jQuery effects.</p>
<h3><a href='http://dev-tips.com/demo/jquery_font_resize_animation.html'>View the Demo</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/jquery-tip-font-resizing-with-animation-effects/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>jQuery Tip : How to Select Radio/Checkbox Input On Click</title>
		<link>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click</link>
		<comments>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click#comments</comments>
		<pubDate>Sun, 11 Jan 2009 01:43:35 +0000</pubDate>
		<dc:creator>Barry Roodt</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=80</guid>
		<description><![CDATA[I've been faced with the following scenario a few times during my web development career : First, you have an unordered list - within each list item you have a radio input. Secondly, when you click on the list item (i.e. the entire container), it must select the radio input and add a css classname [...]]]></description>
			<content:encoded><![CDATA[<p>
I've been faced with the following scenario a few times during my web development career : First, you have an unordered list - within each list item you have a radio input. Secondly, when you click on the list item (i.e. the entire container), it must select the radio input and add a css classname of "selected" to the list item, thus highlighting the item that has been selected.<br />
The following example will explain how to implement a workable solution. For a preview of what we will achieve, check out the <a href='http://dev-tips.com/demo/jquery_radio.html'>demo</a>.
</p>
<p><span id="more-80"></span></p>
<h3>The HTML :</h3>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;!-- include our jquery scripts --&gt;
    &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;script src=&quot;js/radio.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;style type=&quot;text/css&quot;&gt;
    	li { color: #000; }
    	li.selected { color: #FF0000; }
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
	&lt;div&gt;
		&lt;ul&gt;
			&lt;li class=&quot;test&quot;&gt;Test 1 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
			&lt;li class=&quot;test&quot;&gt;Test 2 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
			&lt;li class=&quot;test&quot;&gt;Test 3 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
			&lt;li class=&quot;test&quot;&gt;Test 4 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
			&lt;li class=&quot;test&quot;&gt;Test 5 &lt;input type=&quot;radio&quot; name=&quot;test&quot; /&gt;&lt;/li&gt;
		&lt;/ul&gt;
	&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>There is nothing out of the ordinary here - just a simple unordered list of radio inputs.<br />
There's a basic stylesheet to highlight "selected" items.</p>
<p>For those of you wondering why I'm including the jQuery library from the Google Code repository :</p>
<ol>
<li>It saves on bandwidth, it'll load very quickly from Google's CDN.</li>
<li>It'll already be cached if the user has visited a site which also delivers it from Google Code.</li>
</ol>
<h3>Our Javascript/jQuery:</h3>
<pre class="brush: js">
$(document).ready(function(){
	$(&#039;li&#039;).click( function(){
		$(&#039;li.selected&#039;).removeClass(&#039;selected&#039;);
		$(this).addClass(&#039;selected&#039;).children(&quot;input[@type=radio]&quot;).click();
	});
});
</pre>
<p>As you can see, the actual code involved is short and straightforward - just the way we like it.</p>
<ol>
<li> First - we tell jQuery to execute the following code once the document has finished loading, ensuring that the DOM has been registered successfully.</li>
<li>Next we bind a click event to all list item elements on the page - you can of course change this to all list items with a class of "myselection" for example ( $("li.myselection").click... )</li>
<li>When a list item is clicked - we first need to remove the "selected" class from any previously "selected" list items.</li>
<li>Now we need to add the "selected" class to the list item which fired the event ( $(this) ).</li>
<li> Finally, we need to make sure that the radio button inside the list item is "clicked" : we do this by using the .children() selector and executing a click() event on the input. </li>
</ol>
<p>The important bit is the <strong>.children("input[@type=radio]")</strong> selector. Known as an <a href='http://dev-tips.com/featured/jquery-tip-using-xpath-selectors'>XPath selector</a>. What we're doing here is telling jQuery to find all all radio inputs inside "this" list item. We then use .click() to..as you guessed it... execute a click event on the returned element (in this case the radio input).</p>
<p>And that's all there is to it. You can read up some more on <a href="http://docs.jquery.com/Selectors" title="jQuery docs - selectors">jQuery selectors here</a>.<br />
I would also highly recommend reading the following article : <a href="http://www.tvidesign.co.uk/blog/improve-your-jquery-25-excellent-tips.aspx" title="Improve your jQuery">Improve your jQuery - 25 excellent tips</a>.</p>
<h3><a href='http://dev-tips.com/demo/jquery_radio.html'View the Demo</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/jquery-tip-how-to-select-radiocheckbox-input-on-click/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>jQuery Tip: Animation and CSS Queuing</title>
		<link>http://dev-tips.com/featured/jquery-tip-animation-and-css-queuing</link>
		<comments>http://dev-tips.com/featured/jquery-tip-animation-and-css-queuing#comments</comments>
		<pubDate>Sat, 10 Jan 2009 03:33:23 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=73</guid>
		<description><![CDATA[One of the great things about jQuery is its awesome and powerful animation abilities. Odds are at some point you have played around with the animate function. The question soon comes into play though, how do you queue one animation until the first one is completed? In addition, how do you queue the CSS until [...]]]></description>
			<content:encoded><![CDATA[<p>One of the great things about jQuery is its awesome and powerful animation abilities. Odds are at some point you have played around with the animate function. The question soon comes into play though, how do you queue one animation until the first one is completed? In addition, how do you queue the CSS until the animation is finished?  We'll go over how to easily do this and present a quick demo.</p>
<p><span id="more-73"></span></p>
<h3>Our Goal</h3>
<p>Lets say we want to make a box that animates in a square motion, one animation at a time back to its starting position. When it is back to its position, it should show a hidden message and change its background color. If you want to see the effect we will go after, <a href='http://dev-tips.com/demo/jquery_queue.html' title='queue animation jQuery demo'>check out the demo.</a></p>
<h3>Our HTML and CSS Structure</h3>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
	&lt;meta name=&quot;author&quot; content=&quot;Drew Douglass&quot; /&gt;
	&lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
	&lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
	&lt;title&gt;jQuery Animation and CSS Queue&lt;/title&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot;&gt;&lt;/script&gt;
	&lt;style type=&quot;text/css&quot;&gt;
	#box {
		width:150px;
		height:75px;
		padding:20px;
		background-color:#ccc;
		margin:20px 0px;
		position:relative;
	}
	#box span{
		color:#fff;
		display:block;
	}
	&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;h2&gt;jQuery Queue Animation and CSS Demo.&lt;/h2&gt;
	&lt;input type=&#039;button&#039; id=&#039;start&#039; value=&#039;Start Animation&#039; /&gt;
	&lt;div id=&#039;box&#039;&gt;MightyBox&lt;span&gt;Hello World!&lt;/span&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3>Queuing Animation</h3>
<p>It is actually quite simple to queue one animation until the first has finished. <strong><em>Animation queuing effects are achieved in jQuery by chaining.</em></strong> Lets look at our script so far:</p>
<pre class="brush: javascript">
$(function(){
		$(&#039;#box span&#039;).hide();
		$(&#039;#start&#039;).click(function(){
			$(&#039;#box&#039;).animate({left:500}, 2000)
			.animate({top:150},700)
			.animate({left:0},1200)
</pre>
<p>You can see we have chained the three animations above. The box will slide right, then slide down, then slide back left. We still need the box to slide up, but we need to make sure the background colors change <em>after</em> the box has finished sliding back up. </p>
<h3>CSS Queuing in jQuery</h3>
<p>We can queue our css effects until the box has finished sliding back up by using a call back like so:</p>
<pre class="brush: javascript">
.animate({top:0},700, function(){
				$(&#039;#box span&#039;).show(1000, function(){
				$(&#039;#box&#039;).css(&#039;backgroundColor&#039;, &#039;#333&#039;).css(&#039;color&#039;,&#039;#fff&#039;);
			   });
			});
		});
	});
</pre>
<p>Above, we fadeIn our hidden message and simultaneously change the background and color properties of our box. And that's all there is to it. Be sure to note that we originally hid the span inside our box with jQuery, which is why we can use the fadeIn effect on the element.</p>
<h3>Full Script</h3>
<p>Here is our full animation and css queue script:</p>
<pre class="brush: javascript">
$(function(){
		$(&#039;#box span&#039;).hide();
		$(&#039;#start&#039;).click(function(){
			$(&#039;#box&#039;).animate({left:500}, 2000)
			.animate({top:150},700)
			.animate({left:0},1200)
			.animate({top:0},700, function(){
				$(&#039;#box span&#039;).show(1000, function(){
				$(&#039;#box&#039;).css(&#039;backgroundColor&#039;, &#039;#333&#039;).css(&#039;color&#039;,&#039;#fff&#039;);
			   });
			});
		});
	});
</pre>
<h3>View the Demo</h3>
<p>Be sure to check out the <a href='http://dev-tips.com/demo/jquery_queue.html' title='jQuery animation Demo'>simple demo</a> if your more comfortable exploring the source code.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/jquery-tip-animation-and-css-queuing/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>jQuery Tip: Quick and Easy Font Resizing</title>
		<link>http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing</link>
		<comments>http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing#comments</comments>
		<pubDate>Thu, 08 Jan 2009 03:02:42 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=68</guid>
		<description><![CDATA[One of the many great features of jQuery is how easy it is to edit the css via a user event, such as a click. We can use this to knowledge to edit any css property we wish. Recently, NETTUTS had a great article that went all out with a font resizing slider bar using [...]]]></description>
			<content:encoded><![CDATA[<p>One of the many great features of jQuery is how easy it is to edit the css via a user event, such as a click. We can use this to knowledge to edit any css property we wish. Recently, NETTUTS had a great article that went all out with a <a href='http://nettuts.com/tutorials/javascript-ajax/use-the-jquery-ui-to-control-the-size-of-your-text/' title='Font resizing sliding bar'>font resizing slider bar</a> using the jQuery UI. While this article was certainly in-depth and well done, we want something quick and simple. Today we will create a simple script to allow the user to edit the current font size of an element.</p>
<p><span id="more-68"></span></p>
<h3>Our Goal</h3>
<p>Before starting any project, we need to know what we want to do. We want a simple and quick script to resize the text within a certain element 'on click'.</p>
<h3>Basic HTML</h3>
<p>First thing we need to do is setup our simple HTML page, we will use the code below for the demo.</p>
<pre class="brush: html">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;

&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot;&gt;
&lt;head&gt;
	&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;/&gt;
	&lt;meta name=&quot;author&quot; content=&quot;Drew Douglass&quot; /&gt;
	&lt;meta name=&quot;description&quot; content=&quot;&quot; /&gt;
	&lt;meta name=&quot;keywords&quot; content=&quot;&quot; /&gt;
	&lt;title&gt;jQuery Font Size Change | Dev-Tips&lt;/title&gt;
	&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot;&gt;&lt;/script&gt;
	&lt;script type=&#039;text/javascript&#039;&gt;

	&lt;/script&gt;
&lt;/head&gt;

&lt;body&gt;
	&lt;h2&gt;Text Resizing with jQuery Demo.&lt;/h2&gt;
	&lt;input type=&#039;button&#039; value=&#039;Larger&#039; id=&#039;large&#039; /&gt;
	&lt;input type=&#039;button&#039; value=&#039;Smaller&#039; id=&#039;small&#039; /&gt;
	&lt;p&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h3>Setup some variables</h3>
<p>Now it's time to setup some variables to use later on in our script, I'll explain more after the code below.</p>
<pre class="brush: javascript">
$(function(){
		$(&#039;input&#039;).click(function(){
			var ourText = $(&#039;p&#039;);
			var currFontSize = ourText.css(&#039;fontSize&#039;);
			var finalNum = parseFloat(currFontSize, 10);
			var stringEnding = currFontSize.slice(-2);
</pre>
<p>First we use some shorthand jQuery, which is the same as using document.ready(). Next we will setup some variable to use when the input buttons are clicked. The variable ourText will be our paragraph to re size. The variable currFontSize gets the current font size of the paragraph. The variable finalNum uses the parseFloat function to convert the string into a floating point number (with a base of 10). The variable stringEnding gets the pixels or em ending so we can add it back on later.</p>
<h3>Conditional Statements</h3>
<p>Next we need to decide what to do depending on the button the user is clicking on.</p>
<pre class="brush: javascript">
if(this.id == &#039;large&#039;) {
				finalNum *= 1.2;
			}
			else if (this.id == &#039;small&#039;){
				finalNum /=1.2;
			}
			ourText.css(&#039;fontSize&#039;, finalNum + stringEnding);
		});
	});
</pre>
<p>The above should be pretty self-explanatory. If they clicked on the large button, we multiply the current font size by 1.2, and if they click on the small button the font size is divided by 1.2.</p>
<h3>Full Script</h3>
<p>Our final script looks like this:</p>
<pre class="brush: javascript">
$(function(){
		$(&#039;input&#039;).click(function(){
			var ourText = $(&#039;p&#039;);
			var currFontSize = ourText.css(&#039;fontSize&#039;);
			var finalNum = parseFloat(currFontSize, 10);
			var stringEnding = currFontSize.slice(-2);
			if(this.id == &#039;large&#039;) {
				finalNum *= 1.2;
			}
			else if (this.id == &#039;small&#039;){
				finalNum /=1.2;
			}
			ourText.css(&#039;fontSize&#039;, finalNum + stringEnding);
		});
	});
</pre>
<p>And that's it, we now have a quick and simple font resizing script using jQuery. Don't forget to check out the <a href='http://dev-tips.com/demo/jquery_font_size_change.html' title='jQuery font resize demo'>demo</a> below if you want to see it in action.</p>
<h3><a href='http://dev-tips.com/demo/jquery_font_size_change.html' title='Font resizing demo'>View the Demo</a></h3>
<h3>Update with animation!</h3>
<p>Due to the popularity of this article, we have published another font resizing script, this time with animations on the resize. Be sure to check it out '<a href='http://dev-tips.com/featured/jquery-tip-font-resizing-with-animation-effects'>Font resizing with animation effects.</a>'.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/jquery-tip-quick-and-easy-font-resizing/feed</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>jQuery Tip: Resources for Creating Your Own Plugins</title>
		<link>http://dev-tips.com/featured/jquery-tip-resources-for-creating-your-own-plugins</link>
		<comments>http://dev-tips.com/featured/jquery-tip-resources-for-creating-your-own-plugins#comments</comments>
		<pubDate>Tue, 06 Jan 2009 13:10:02 +0000</pubDate>
		<dc:creator>Drew Douglass</dc:creator>
				<category><![CDATA[Client Side]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dev-tips.com/?p=51</guid>
		<description><![CDATA[With jQuery easily becoming the quickest growing Javascript library on the market right now, it's no wonder the demand for quality tutorials is so high. One of jQuerys great features is the ability for anyone to quickly and easily create a plugin. Today, we will have a look at some extremely helpful resources to get [...]]]></description>
			<content:encoded><![CDATA[<p>With jQuery easily becoming the quickest growing Javascript library on the market right now, it's no wonder the demand for quality tutorials is so high. One of jQuerys great features is the ability for anyone to quickly and easily create a plugin. Today, we will have a look at some extremely helpful resources to get you started with created your own jQuery plugins.<br />
<span id="more-51"></span></p>
<h2>The Definite Guide to Creating a Practical Plugin</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img1.jpg' alt='Screenshot 1' /></div>
<p>First up we have an excellent article by Dan Wellman over at <a href='http://nettuts.com' title='NETTUTS'>NETTUTS.</a> This article is extremely in depth and aimed towards those who are new to jQuery but have used it before.</p>
<h3><a href='http://nettuts.com/tutorials/javascript-ajax/the-definitive-guide-to-creating-a-practical-jquery-plugin/' title='Creating a practical plugin'>Visit Article</a></h3>
<h2>Developing a jQuery plugin via Snook.ca</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img2.jpg' alt='Screenshot 2' /></div>
<p>Anyone who knows me knows that I am stalking Jonathan Snook. OK, maybe not stalking but the guy is a web dev hero. In this article he takes us through the process of getting ready to create your plugin and putting the code into action.</p>
<h3><a href='http://snook.ca/archives/javascript/jquery_plugin/' title='Snook.ca Plugin'>Visit Article</a></h3>
<h2>Building Your First jQuery Plugin</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img3.jpg' alt='Screenshot 3' /></div>
<p>In this plugin tutorial you learn how to create a plugin which truncates text, or in other words, allows you have a a drop down 'read more' effect.</p>
<h3><a href='http://blog.jeremymartin.name/2008/02/building-your-first-jquery-plugin-that.html' title='Building your first jquery plugin'>Visit Article</a></h3>
<h2>A Plugin Development Pattern</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img4.jpg' alt='Screenshot 4' /></div>
<p><a href='http://learningjquery.com' title='Learning jQuery'>Learning jQuery</a> brings us an excellent article aimed more towards the development steps and patterns of developing a basic jQuery plugin.</p>
<h3><a href='http://www.learningjquery.com/2007/10/a-plugin-development-pattern' title=''>Visit Article</a></h3>
<h2>Learn How to Create a jQuery Plugin</h2>
<div class='roundupImg'><img src='http://dev-tips.com/post_img/jquery_plugin_resources/img5.jpg' alt='Screenshot 5' /></div>
<p>Again, NETTUTS delivers with a quality tutorial on every single step of creating your first jQuery plugin. Be sure to check out <a href='http://blog.themeforest.net/tutorials/jquery-for-absolute-beginners-day-15/' title='jQuery for absolute beginners'>jQuery for absolute beginners</a>, a 15 day series by Jeffrey Way on the ThemeForest blog for some excellent tuts.</p>
<h3><a href='http://nettuts.com/javascript-ajax/learn-how-to-create-a-jquery-plugin/' title='Visit article'>Visit Article</a></h3>
]]></content:encoded>
			<wfw:commentRss>http://dev-tips.com/featured/jquery-tip-resources-for-creating-your-own-plugins/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
