<?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>scriptygoddess &#187; jquery</title>
	<atom:link href="http://www.scriptygoddess.com/archives/category/javascript/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scriptygoddess.com</link>
	<description></description>
	<lastBuildDate>Thu, 08 Dec 2011 18:23:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>launch all external links in a new window with jQuery</title>
		<link>http://www.scriptygoddess.com/archives/2011/04/06/launch-all-external-links-in-a-new-window-with-jquery/</link>
		<comments>http://www.scriptygoddess.com/archives/2011/04/06/launch-all-external-links-in-a-new-window-with-jquery/#comments</comments>
		<pubDate>Wed, 06 Apr 2011 19:38:39 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1669</guid>
		<description><![CDATA[This is a really simple piece of jquery that will launch all external links on the page in a new window. jQuery(document).ready(function(){ jQuery("a[href*='http://']:not([href*='http://yourdomain.com'])").attr("target","_blank"); jQuery("a[href*='https://']:not([href*='https://yourdomain.com'])").attr("target","_blank"); }); Updated to add: Here is a modification in case you want to allow links to subdomains to open in the same window&#8230; jQuery("a[href*='http://']:not([href*='http://yourdomain.com'])").not("[href^='http://subdomain.yourdomain.com']").attr("target","_blank"); Another update Here is another modification that [...]
Related posts:<ol>
<li><a href='http://www.scriptygoddess.com/archives/2011/02/09/wordpress-emails-being-sent-by-usernamebox-bluehost-com-fix/' rel='bookmark' title='WordPress emails being sent by {username}@box###.bluehost.com (fix)'>WordPress emails being sent by {username}@box###.bluehost.com (fix)</a> <small>If you are hosted on Bluehost and you&#039;re using WordPress,...</small></li>
</ol>

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>This is a really simple piece of jquery that will launch all external links on the page in a new window. </p>
<p><code>jQuery(document).ready(function(){<br />
jQuery("a[href*='http://']:not([href*='http://yourdomain.com'])").attr("target","_blank");<br />
jQuery("a[href*='https://']:not([href*='https://yourdomain.com'])").attr("target","_blank");<br />
}); </code></p>
<p><strong>Updated to add:</strong> Here is a modification in case you want to allow links to subdomains to open in the same window&#8230;</p>
<p><code>jQuery("a[href*='http://']:not([href*='http://yourdomain.com'])").not("[href^='http://subdomain.yourdomain.com']").attr("target","_blank");</code></p>
<p><strong>Another update</strong> Here is another modification that will work in a PHP page and automatically enter the current domain in:</p>
<p><code>jQuery(document).ready(function(){<br />
jQuery("a[href*='http://']:not([href*='http://&lt;?php echo $_SERVER['HTTP_HOST']; ?&gt;'])").attr("target","_blank");<br />
jQuery("a[href*='https://']:not([href*='https://&lt;?php echo $_SERVER['HTTP_HOST']; ?&gt;'])").attr("target","_blank");<br />
});</code></p>
<p>Related posts:<ol>
<li><a href='http://www.scriptygoddess.com/archives/2011/02/09/wordpress-emails-being-sent-by-usernamebox-bluehost-com-fix/' rel='bookmark' title='WordPress emails being sent by {username}@box###.bluehost.com (fix)'>WordPress emails being sent by {username}@box###.bluehost.com (fix)</a> <small>If you are hosted on Bluehost and you&#039;re using WordPress,...</small></li>
</ol></p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2011/04/06/launch-all-external-links-in-a-new-window-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding alternate row styles to a table with JQuery</title>
		<link>http://www.scriptygoddess.com/archives/2009/08/08/adding-alternate-row-styles-to-a-table-with-jquery/</link>
		<comments>http://www.scriptygoddess.com/archives/2009/08/08/adding-alternate-row-styles-to-a-table-with-jquery/#comments</comments>
		<pubDate>Sun, 09 Aug 2009 01:24:44 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1611</guid>
		<description><![CDATA[JQuery&#039;s simplicity is so wonderful and powerful. Here&#039;s a perfect example. If you have a table, and you want to alternate the row colors. To do so, all you need is this: $(document).ready(function() { $("table.striped tr:nth-child(even)").addClass("altrow"); }); Then, just add class=&#034;striped&#034; to your table tag, and jquery will automatically apply add the class &#034;altrow&#034; to [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>JQuery&#039;s simplicity is so wonderful and powerful. Here&#039;s a perfect example. If you have a table, and you want to alternate the row colors. To do so, all you need is this:</p>
<p><code>$(document).ready(function() {<br />
	$("table.striped tr:nth-child(even)").addClass("altrow");<br />
});</code></p>
<p>Then, just add class=&#034;striped&#034; to your table tag, and jquery will automatically apply add the class &#034;altrow&#034; to every other row. (If you want to change which row it starts with &#8211; change &#039;even&#039; to &#039;odd&#039; in the code above).</p>
<p>Then just include a style for your altrow:</p>
<p><code>table.striped tr.altrow td {<br />
background-color: #ccc;<br />
}</code></p>
<p>And to think I used to do that manually. OY!</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2009/08/08/adding-alternate-row-styles-to-a-table-with-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Multi-Row Carousel and Image Loader with JQuery</title>
		<link>http://www.scriptygoddess.com/archives/2009/03/23/multi-row-carousel-and-image-loader-with-jquery/</link>
		<comments>http://www.scriptygoddess.com/archives/2009/03/23/multi-row-carousel-and-image-loader-with-jquery/#comments</comments>
		<pubDate>Mon, 23 Mar 2009 18:04:09 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Scripts]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1608</guid>
		<description><![CDATA[A recent project I&#039;ve been working on involved a portfolio page that required a &#034;carousel&#034; type browser. It also needed to have multiple rows (so that images could be grouped into various projects). Also, because this page would contain a large number of images, it was required that the images not be loaded until you [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>A recent project I&#039;ve been working on involved a portfolio page that required a &#034;carousel&#034; type browser. It also needed to have multiple rows (so that images could be grouped into various projects). Also, because this page would contain a large number of images, it was required that the images not be loaded until you pulled up that particular project/row in the carousel. </p>
<p>There are a lot of carousel scripts out there, and there is a <a href="http://flesler.blogspot.com/2008/02/jqueryserialscroll.html">scrolling plugin</a> that I had been counting on to help me create what I needed &#8211; but to be honest, either I couldn&#039;t get those scripts to work the way I wanted them to, or I couldn&#039;t get them to work AT ALL. I spent a few frustrating days fighting with the plugins, when I finally threw in the towel. I knew what I wanted to do, and figured I&#039;d be better off hand coding specifically what I needed instead of retrofitting a pre-made plugin or script. It turned out to be less time consuming, and in the end I got exactly what I wanted.</p>
<p>So while this script was for a specific purpose, I thought I would put it out here anyway on the chance that it might work for or help someone else. It&#039;s probably possible to &#034;package it up&#034; into a more modular plugin.</p>
<p>So first <a href="http://www.scriptygoddess.com/resources/1608/multi-row-carousel.htm">here is the very rough, proof of concept/demo.</a> (no design on that page &#8211; just wanted to show how the script works) <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><a href="http://www.scriptygoddess.com/resources/1608/multi-row-carousel.zip">Here you can download all the files</a> (except the photos &#8211; I originally grabbed them from <a href="http://www.sxc.hu/">stock.xchng</a>)</p>
<p>I&#039;ll walk through just a few of the details of how the HTML needs to be structured in order to get the script to work &#8211; but the files in the zip are well commented and should explain the rest.</p>
<p>One important trick with this script is that there are some &#034;naming conventions&#034; that it relies on. Each row of photos is setup as a unordered list. The ID of that unordered list is used as a base for naming other related elements. So for example &#8211; the first row is named with and ID of &#034;row1&#034; &#8211; I use that base for the ID of a div that contains links to the images in that row. I want this div to only appear when that row1 is being shown. So the ID of the div needs to be created like <strong>ROW BASE NAME + &#034;-nav&#034;</strong>. So, specifically: &#034;<strong>row1-nav</strong>&#034;.</p>
<p>You&#039;ll notice in the HTML when I link to rows or specific images in the row &#8211; I didn&#039;t put the id of the image inside the &#034;href&#034; element. I actually repurposed the &#034;rel&#034; attribute and put the image I wanted to display in the carousel in that. (The script didn&#039;t work quite right if I put the row name in the href value). </p>
<p>Another &#034;repurpose&#034; I&#039;ve done is for use with the delayed image loading. In each of the LI element, I &#034;store&#034; the path to the image that will be loaded inside the LI element in the &#034;title&#034; tag.</p>
<p>I&#039;ve pulled out as many &#034;variables&#034; as I could in the javascript.js &#8211; row names, image names, classnames &#8211; and explained what they are and how they relate to the HTML in the comments to make reusing the code as easy as possible.</p>
<p>So an important note, I don&#039;t claim this to be an easy to use plugin. If you&#039;re going to use this script, you do have to some level of understanding of jquery, javascript, html. I also can&#039;t promise too much (un-paid) support. If you want to use it, you&#039;re welcome to it &#8211; please leave the credit lines in place &#8211; I spent quite a bit of time getting this to work. And for my own curiosity, I&#039;d love it if you came back here and posted a link to where you&#039;re using it. If you can&#039;t get it to work, you&#039;re welcome to post a question here, but I can&#039;t guarantee I&#039;ll be able to help out.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2009/03/23/multi-row-carousel-and-image-loader-with-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>jQuery Side Scroll</title>
		<link>http://www.scriptygoddess.com/archives/2009/02/01/jquery-side-scroll/</link>
		<comments>http://www.scriptygoddess.com/archives/2009/02/01/jquery-side-scroll/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 07:02:56 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1577</guid>
		<description><![CDATA[(This post has been almost completely re-written. Usually I don&#039;t that &#8211; but I thought it would be more confusing to have all the changes, strikeouts, etc.) For a project I&#039;m going to be working on, I needed to create a navigation piece that had different panes scrolling/sliding in from the right depending on what [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>(This post has been almost completely re-written. Usually I don&#039;t that &#8211; but I thought it would be more confusing to have all the changes, strikeouts, etc.)</p>
<p>For a project I&#039;m going to be working on, I needed to create a navigation piece that had different panes scrolling/sliding in from the right depending on what item you clicked. I&#039;ve seen lots of options for vertical accordions. Not as many, but a few, options for horizontal accordions. My situation was unique in that the click was not near or part of the scrolling panes. And it should disappear completely out of view if not the current pane so that if clicked again, it would again animate in. But if already in view &#8211; I wanted it to stay until the new pane coming in covered it completely.</p>
<p>Went through a few versions of this, and finally I have something I&#039;m satisfied with. <a href="http://www.scriptygoddess.com/resources/jquery-side-scroll/blockslider-absoluteposition-ver3.html">Here&#039;s the demo.</a></p>
<p>View source on that page to see the full html and jquery code. Now I&#039;ll walk you through what my logic was&#8230;</p>
<p><code>var lastpane;<br />
var href;<br />
var zcount = 2;<br />
var inprogress = false;</code></p>
<p>That&#039;s just calling out some variables we&#039;ll be using in various iterations. &#034;href&#034; will be used to hold a reference to the current element/pane. &#034;zcount&#034; will make sure the current pane always has the highest z-index. &#034;inprogress&#034; will keep track of whether there is currently a pane being animated or not and will hold the other clicks/animations until the current pane animation is complete</p>
<p><code>$('a').click(function(){</code></p>
<p>Obviously, if this gets used in something other than a proof of concept, you&#039;ll probably have to be more specific about WHICH &#039;a&#039; &#8211; ie &#8211; give the links you want to use for this a style like class=&#034;paneslider&#034; and then change that to $(&#039;a.paneslider&#039;)&#8230; etc. In any case, the above just says, run the following whenever a link is clicked.</p>
<p><code>if (!inprogress &#038;&#038; $(this).attr('title') != lastpane) {</code></p>
<p>Here I&#039;m checking to make sure that an animation isn&#039;t already in progress, and the currently clicked link does not match the pane currently in view. (Which would have been defined as &#034;lastpane&#034;</p>
<p><code>inprogress = true;<br />
zcount = zcount+1;</code></p>
<p>Set in progress to true right away so that we don&#039;t have conflicting animations. And add 1 to zcount (z-index), which will make the current pane appear above any other that is visible.</p>
<p><code>$(lastpane).css("z-index","1");</code></p>
<p>Give the last element pane shown (defined as &#034;lastpane&#034;) a z-index of 1 to make sure it appears below the pane we want to have move across the screen.</p>
<p><code>var href = $(this).attr('href');</code></p>
<p>Now we&#039;ll redefine href as the current pane we want to animate. (This, by the way is set in the html &#8211; in the &#034;a&#034; tag using the &#034;title&#034; attribute).</p>
<p><code>$(href).css("left","800px");<br />
$(href).css("z-index",zcount);</code></p>
<p>Make sure that the current pane is starting out completely out of view, and then giving it the highest z-index.</p>
<p><code>$(href).animate({"left": "0"}, 2000, function() {</code></p>
<p>Now we start our animation. Move it across to absolute position of 0 in 2000 milliseconds. As well we use a callback function to do the following after the pane finished moving.</p>
<p><code>$(lastpane).css("left","800px");<br />
lastpane = href;<br />
inprogress = false;</code></p>
<p>We move the pane that is now hidden under the current pane back to the &#034;starting&#034; position &#8211; and then we redefine &#034;lastpane&#034; with the pane that is now currently visible. And now that everything else is done, &#034;inprogress&#034; gets set back to false so we&#039;re open to run another pane across.</p>
<p>Then the rest of the code is all closing brackets etc.</p>
<p>Just for fun, I have another version of the sliding pane thing using the &#034;<a href="http://gsgd.co.uk/sandbox/jquery/easing/">easing plugin</a>&#034;. <a href="http://www.scriptygoddess.com/resources/jquery-side-scroll/blockslider-absoluteposition-ver3-withbounce.html">Here&#039;s the demo using a bounce as it comes in</a>.</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2009/02/01/jquery-side-scroll/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Overlapping Tabbed Navigation using CSS and jQuery</title>
		<link>http://www.scriptygoddess.com/archives/2008/09/20/overlapping-tabbed-navigation-using-css-and-jquery/</link>
		<comments>http://www.scriptygoddess.com/archives/2008/09/20/overlapping-tabbed-navigation-using-css-and-jquery/#comments</comments>
		<pubDate>Sat, 20 Sep 2008 20:51:13 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1528</guid>
		<description><![CDATA[Recently had a project land on my desk that required tabbed navigation that overlap one another. Just so we&#039;re clear on what we&#039;re doing: here&#039;s the demo. Here is how I did it: 1) Each tab has four &#034;states&#034; &#8211; Off, Off (with right tab on), On, On (with right tab on). I combined each [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Recently had a project land on my desk that required tabbed navigation that overlap one another. Just so we&#039;re clear on what we&#039;re doing: <a href="/resources/1528/overlappingtabs.html">here&#039;s the demo</a>. Here is how I did it:</p>
<p>1) Each tab has four &#034;states&#034; &#8211; Off, Off (with right tab on), On, On (with right tab on). I combined each of these four states in the one image for each tab. So it looks like this:</p>
<p><img src="/resources/1528/css/images/nav_about.gif" /></p>
<p>2) The HTML is pretty simple and looks like this:</p>
<p><code>&lt;div id="navbar"&gt;<br />
&lt;ul&gt;<br />
&lt;li id="nav_home"&gt;&lt;a href="#"&gt;&lt;span&gt;Home&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="nav_about"&gt;&lt;a href="#"&gt;&lt;span&gt;About Us&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="nav_products" class="right"&gt;&lt;a href="#"&gt;&lt;span&gt;Products&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="nav_sales" class="current"&gt;&lt;a href="#"&gt;&lt;span&gt;Sales Reps&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;li id="nav_contact"&gt;&lt;a href="#"&gt;&lt;span&gt;Contact Us&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&lt;/ul&gt;<br />
&lt;/div&gt;</code></p>
<p>Notice that when one of the tabs is set as the &#034;current&#034; tab &#8211; we also need to define the tab before it with a class of &#034;right&#034; (meaning that the tab to the right of this one is set as &#034;on&#034;)</p>
<p>3) Then we define the various states in CSS. In this case, all the tabs are the same width and height:</p>
<p><code>#navbar li {<br />
float: left;<br />
}<br />
#navbar li a {<br />
display: block;<br />
height: 29px;<br />
width: 91px;<br />
}</code></p>
<p>Hide the text with css since we&#039;re using images for the tabs:</p>
<p><code>#navbar li a span {<br />
margin: 0 0 0 -100000px;<br />
}</code></p>
<p>Define the image to be used for each tab:</p>
<p><code>#nav_home a {<br />
background:url(images/nav_home.gif) top left no-repeat;<br />
}<br />
#nav_about a {<br />
background:url(images/nav_about.gif) top left no-repeat;<br />
}<br />
#nav_products a {<br />
background:url(images/nav_products.gif) top left no-repeat;<br />
}<br />
#nav_sales a {<br />
background:url(images/nav_sales.gif) top left no-repeat;<br />
}<br />
#nav_contact a {<br />
background:url(images/nav_contact.gif) top left no-repeat;<br />
}</code></p>
<p>4) I&#039;m going to skip over the rest of the class definitions and move to the jquery part &#8211; because I think it will make more sense to see how the classes are being defined if you see what class I&#039;m applying when and where.</p>
<p><code>&lt;script type="text/javascript" src="js/jquery-1.2.6.min.js"&gt;&lt;/script&gt;<br />
&lt;script type="text/javascript"&gt;<br />
var j = jQuery.noConflict();<br />
j(document).ready( function() {<br />
	j('#nav_about a').hover(function() {<br />
		j('#nav_home a').addClass("left");<br />
	}, function() {<br />
		j('#nav_home a').removeClass("left");<br />
	});<br />
	j('#nav_products a').hover(function() {<br />
		j('#nav_about a').addClass("left");<br />
	}, function() {<br />
		j('#nav_about a').removeClass("left");<br />
	});<br />
	j('#nav_sales a').hover(function() {<br />
		j('#nav_products a').addClass("left");<br />
	}, function() {<br />
		j('#nav_products a').removeClass("left");<br />
	});<br />
	j('#nav_contact a').hover(function() {<br />
		j('#nav_sales a').addClass("left");<br />
	}, function() {<br />
		j('#nav_sales a').removeClass("left");<br />
	});<br />
});<br />
&lt;/script&gt;</code></p>
<p>So what I&#039;m doing here is, anytime I mouseover a tab, I&#039;m adding the class &#034;left&#034; to the &lt;a&gt; tag in the tab <em>in front of</em> the one my mouse is on.</p>
<p>So if the tab <em>in front of</em> the one my mouse is on is &#034;off&#034; &#8211; then we need to change that tab to state #2 (Off &#8211; with the tab next to it on). If that tab has the class &#034;current&#034; applied to the li tag &#8211; then we need to move that tab to state #4 &#8211; (On &#8211; with the tab next to it on).</p>
<p>4) So on to the various states with css&#8230;.</p>
<p>When hovering &#8211; we go to the &#034;on&#034; state &#8211; (in this case, when tab is current, it lookes the same as when we mouse over it.) So the most basic state &#8211; state #3: Whether the tab is current, or hovering &#8211; move to that &#034;Third&#034; state: On &#8211; with the tab next door off.<br />
<code>#navbar li.current a,<br />
#navbar a:hover {<br />
background-position: 0 -58px;<br />
}</code></p>
<p>This is for state #2: Off &#8211; with the tab next to us as On. (the &#034;.right&#034; class applied to the li tag means that the tab in front is &#034;current&#034;)<br />
<code>#navbar li.right a,<br />
#navbar li a.left {<br />
background-position: 0 -29px;<br />
}</code></p>
<p>This is for state #4 &#8211; On with the tab next to us as on.<br />
<code>#navbar li.right a:hover,<br />
#navbar li.current a.left {<br />
background-position: 0 -87px;<br />
}</code></p>
<p>One thing to note &#8211; the last tab really only has two states &#8211; because there is no tab in front of it &#8211; but to keep things simple in the code and css &#8211; I just made the image with the extra versions. This way it could have the same styles applied to it &#8211; without having to make a special case for it.</p>
<p>Here are some more demos:</p>
<p><a href="/resources/1528/overlappingtabs1.html">No tab set as current</a></p>
<p><a href="/resources/1528/overlappingtabs2.html">Home tab set as current</a> (no &#034;right&#034; class needs to be applied &#8211; since home is the first tab)</p>
<p><a href="/resources/1528/overlappingtabs3.html">Last tab set as current</a></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2008/09/20/overlapping-tabbed-navigation-using-css-and-jquery/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery Method for Validation Plugin &#8211; &quot;field must include at least one number&quot;</title>
		<link>http://www.scriptygoddess.com/archives/2008/09/07/jquery-method-for-validation-plugi-field-must-include-at-least-one-number/</link>
		<comments>http://www.scriptygoddess.com/archives/2008/09/07/jquery-method-for-validation-plugi-field-must-include-at-least-one-number/#comments</comments>
		<pubDate>Sun, 07 Sep 2008 21:37:45 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1524</guid>
		<description><![CDATA[Here&#039;s a method you can use with the validation jQuery plugin to make sure a field (like a password field) includes at least one number. $.validator.addMethod("atleastonedigit", function(pass) { if (pass == "") { return true; } return ((/[0-9]+/).test(pass)); }, "This field must contain at least one number"); No related posts. Related posts brought to you [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>Here&#039;s a method you can use with the <a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">validation jQuery plugin</a> to make sure a field (like a password field) includes at least one number.</p>
<p><code>$.validator.addMethod("atleastonedigit", function(pass) {<br />
if (pass == "") {<br />
return true;<br />
}<br />
return ((/[0-9]+/).test(pass));<br />
}, "This field must contain at least one number");</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2008/09/07/jquery-method-for-validation-plugi-field-must-include-at-least-one-number/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Phone number validation with jquery</title>
		<link>http://www.scriptygoddess.com/archives/2008/05/03/phone-number-validation-with-jquery/</link>
		<comments>http://www.scriptygoddess.com/archives/2008/05/03/phone-number-validation-with-jquery/#comments</comments>
		<pubDate>Sun, 04 May 2008 06:43:44 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/?p=1517</guid>
		<description><![CDATA[One of the things I&#039;ve been playing around with a lot recently is jquery. Why I didn&#039;t jump on this bandwagon sooner, I&#039;m not sure, but I am kicking myself for it. So I am still a bit of nub on the jquery front &#8211; but I like to think I pick things up quickly. [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>One of the things I&#039;ve been playing around with a lot recently is jquery. Why I didn&#039;t jump on this bandwagon sooner, I&#039;m not sure, but I am kicking myself for it. So I am still a bit of nub on the jquery front &#8211; but I like to think I pick things up quickly. <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So one thing I am now using jquery regularly for is form validation. <a href="http://www.scriptygoddess.com/archives/2003/02/09/javascript-validation/">Previously, form validation used to mean a lot of script writing</a>, not to mention a fair amount of dread.</p>
<p><a href="http://bassistance.de/jquery-plugins/jquery-plugin-validation/">Now it&#039;s quite painless.</a></p>
<p>My current usage of that plugin is pretty basic until I get a better handle of it. But one thing that I have been requested a number of times, is to add validation for a phone number &#8211; which is not included in that plugin. I&#039;m not sure this is the &#034;right&#034; or best way to do it &#8211; but it does work. <img src='http://www.scriptygoddess.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The functions are basically the same as those provided <a href="http://www.smartwebby.com/DHTML/phone_no_validation.asp">here</a> with some minor modifications and altered to be used with the jquery plugin.</p>
<p>First of course you include the jquery javascript file:<br />
<code>&lt;script language="javascript" type="text/javascript" src="/js/jquery.min.js"&gt;&lt;/script&gt;</code></p>
<p>Then the validation plugin:<br />
<code>&lt;script type="text/javascript" src="/js/jquery.validate.pack.js"&gt;&lt;/script&gt;</code></p>
<p>Then you add the function to check the phone number:<br />
<code>&lt;script type="text/javascript"&gt;<br />
$.validator.addMethod("phone", function(phone_number, element) {<br />
var digits = "0123456789";<br />
var phoneNumberDelimiters = "()- ext.";<br />
var validWorldPhoneChars = phoneNumberDelimiters + "+";<br />
var minDigitsInIPhoneNumber = 10;<br />
s=stripCharsInBag(phone_number,validWorldPhoneChars);<br />
return this.optional(element) || isInteger(s) &#038;&#038; s.length &gt;= minDigitsInIPhoneNumber;<br />
}, "Please enter a valid phone number");</code></p>
<p>Some &#034;helper&#034; functions:<br />
<code>function isInteger(s)<br />
{   var i;<br />
    for (i = 0; i &lt; s.length; i++)<br />
    {<br />
        // Check that current character is number.<br />
        var c = s.charAt(i);<br />
        if (((c &lt; "0") || (c &gt; "9"))) return false;<br />
    }<br />
    // All characters are numbers.<br />
    return true;<br />
}<br />
function stripCharsInBag(s, bag)<br />
{   var i;<br />
    var returnString = "";<br />
    // Search through string's characters one by one.<br />
    // If character is not in bag, append to returnString.<br />
    for (i = 0; i &lt; s.length; i++)<br />
    {<br />
        // Check that current character isn't whitespace.<br />
        var c = s.charAt(i);<br />
        if (bag.indexOf(c) == -1) returnString += c;<br />
    }<br />
    return returnString;<br />
}</code></p>
<p>Then the line that makes the jquery run:<br />
<code>$(document).ready(function() {<br />
	$("#myform").validate();<br />
});<br />
&lt;/script&gt;</code></p>
<p>To use the jquery validation plugin &#8211; I was just adding &#034;required&#034; as a class to those fields that were required. Like this:<br />
<code>&lt;input type="text" name="FirstName" class="required" /&gt;</code></p>
<p>You can check email structure by also adding the class &#034;email&#034;.<br />
<code>&lt;input type="text" name="EmailAddress" class="required email" /&gt;</code></p>
<p>And now, using the code above, if you add the class &#034;phone&#034; &#8211; it will check a phone number.<br />
<code>&lt;input type="text" name="PhoneNumber" class="required phone" /&gt;</code></p>
<p>(My code above allows for some additional characters beyond just numbers &#8211; so that it will accept parens around the area code &#8211; dashes or periods between the numbers and &#034;e&#034; &#034;x&#034; &#034;t&#034; characters as well &#8211; in case someone needs to include an extension.)</p>
<p>Typical disclaimer &#8211; like I said &#8211; I&#039;m still a nub at jquery. There may be a better/easier way to do the above, so as always feel free to chime in if you know what that better/easier way is&#8230;</p>
<p><strong>Updated 5/5/08</strong> I do see a &#034;phone&#034; method in the &#034;additional-methods.js&#034; file&#8230; but I needed it do things a little differently&#8230; (like allowing extension numbers etc.)</p>
<p><strong>Updated 5/29/08</strong> Had some issues with the method not allowing phone fields to be optional and only checking the values if something was entered (when optional). Fixed that now.</p>
<p><strong>Updated 7/1/08</strong> As JT noted in the comments with regex this can be simplified. JT provided the following code:<br />
<code>function isValidPhoneNumber(ph) {<br />
   if (ph == null) {<br />
       return false;<br />
   }<br />
   var stripped = ph.replace(/[\s()+-]|ext\.?/gi, "");<br />
   // 10 is the minimum number of numbers required<br />
   return ((/\d{10,}/i).test(stripped));<br />
}</code></p>
<p>So to update the jquery:<br />
<code>$.validator.addMethod("phone", function(ph, element) {<br />
if (ph == null) {<br />
       return false;<br />
   }<br />
   var stripped = ph.replace(/[\s()+-]|ext\.?/gi, "");<br />
   // 10 is the minimum number of numbers required<br />
   return ((/\d{10,}/i).test(stripped));<br />
}, "Please enter a valid phone number");</code></p>
<p>And then you can loose the other &#034;helper&#034; functions. (Thanks JT!!)</p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2008/05/03/phone-number-validation-with-jquery/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Javascript set selection in select element</title>
		<link>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/</link>
		<comments>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/#comments</comments>
		<pubDate>Tue, 06 Feb 2007 21:29:30 +0000</pubDate>
		<dc:creator>Jennifer</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Script snippet]]></category>

		<guid isPermaLink="false">http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/</guid>
		<description><![CDATA[I needed to set the selection of a drop down menu. As far as I can tell, if you don&#039;t know the &#034;index&#034; value, then you just have to loop through to set the item as selected. If there&#039;s an easier way to do this, please speak up in the comments. I spent WAY too [...]
No related posts.

Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.]]></description>
			<content:encoded><![CDATA[<p>I needed to set the selection of a drop down menu. As far as I can tell, if you don&#039;t know the &#034;index&#034; value, then you just have to loop through to set the item as selected. If there&#039;s an easier way to do this, please speak up in the comments. I spent WAY too long hunting for a better solution, but this was the only thing that worked:</p>
<p><code>for (var i=0; i &lt; document.formname.dropdownboxname.length; i++) {<br />
if (document.formname.dropdownboxname[i].value == <em>"value"</em>) {<br />
document.formname.dropdownboxname[i].selected = true;<br />
}<br />
}</code></p>
<p><strong>Update</strong> Posting my comment in the main post &#8211; because this is the way to do it right: Use jQuery because it rules.</p>
<p>Use this plugin:<br />
<a href="http://www.texotela.co.uk/code/jquery/select/">http://www.texotela.co.uk/code/jquery/select/</a></p>
<p>And this code:<br />
<code>$(document).ready(function() {<br />
$(”#selectboxname”).selectOptions(”The Select Value”, true);<br />
});</code></p>
<p>No related posts.</p>
<p>Related posts brought to you by <a href='http://yarpp.org'>Yet Another Related Posts Plugin</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.scriptygoddess.com/archives/2007/02/06/javascript-set-selection-in-select-element/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
	</channel>
</rss>

