<?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>12 Stix - Tech Answers and Fixes &#187; jquery</title>
	<atom:link href="http://12stix.com/category/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://12stix.com</link>
	<description>Tech Answers and Fixes</description>
	<lastBuildDate>Fri, 03 Sep 2010 14:24:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>How to add onclick values to a list in Jquery</title>
		<link>http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/</link>
		<comments>http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 09:32:05 +0000</pubDate>
		<dc:creator>Pete</dc:creator>
				<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://12stix.com/?p=173</guid>
		<description><![CDATA[This bit of jquery will add an onclick value to list items based on the link within the list item. The idea is that the whole lists items become links rather than just the link text. Its ideal if you want to colour the background of a list item and have it clickable. &#60;script type=&#34;text/javascript&#34;&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>This bit of jquery will add an onclick value to list items based on the link within the list item.</p>
<p>The idea is that the whole lists items become links rather than just the link text. Its ideal if you want to colour the background of a list item and have it clickable.</p>
<pre class="brush: javascript">
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function(){
$(&quot;li&quot;).each(function(){
var url = &quot;location.href=&#039;&quot;+$(&quot;a&quot;, this).attr(&quot;href&quot;)+&quot;&#039;&quot;;
$(this).attr(&#039;onclick&#039;, url);
});
$(&quot;li&quot;).each(function(){
var url = &quot;location.href=&#039;&quot;+$(&quot;a&quot;, this).attr(&quot;href&quot;)+&quot;&#039;&quot;;
$(this).attr(&#039;onclick&#039;, url);
});
});
&lt;/script&gt;
</pre>
<p>The only downside to this method is if you have a list within a list such as a nested Drupal menu.</p>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-shr">
<ul class="socials">
		<li class="shr-comfeed">
			<a href="http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/feed" rel="nofollow" class="external" title="Subscribe to the comments for this post?">Subscribe to the comments for this post?</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/&amp;title=How+to+add+onclick+values+to+a+list+in+Jquery" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/&amp;title=How+to+add+onclick+values+to+a+list+in+Jquery" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-diigo">
			<a href="http://www.diigo.com/post?url=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/&amp;title=How+to+add+onclick+values+to+a+list+in+Jquery&amp;desc=This%20bit%20of%20jquery%20will%20add%20an%20onclick%20value%20to%20list%20items%20based%20on%20the%20link%20within%20the%20list%20item.%0D%0A%0D%0AThe%20idea%20is%20that%20the%20whole%20lists%20items%20become%20links%20rather%20than%20just%20the%20link%20text.%20Its%20ideal%20if%20you%20want%20to%20colour%20the%20background%20of%20a%20list%20item%20and%20have%20it%20clickable.%0D%0A%0D%0A%5Bsourcecode%20language%3D%27java" rel="nofollow" class="external" title="Post this on Diigo">Post this on Diigo</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-misterwong">
			<a href="http://www.mister-wong.com/addurl/?bm_url=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/&amp;bm_description=How+to+add+onclick+values+to+a+list+in+Jquery&amp;plugin=sexybookmarks" rel="nofollow" class="external" title="Add this to Mister Wong">Add this to Mister Wong</a>
		</li>
		<li class="shr-mixx">
			<a href="http://www.mixx.com/submit?page_url=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/&amp;title=How+to+add+onclick+values+to+a+list+in+Jquery" rel="nofollow" class="external" title="Share this on Mixx">Share this on Mixx</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/&amp;title=How+to+add+onclick+values+to+a+list+in+Jquery" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/&amp;title=How+to+add+onclick+values+to+a+list+in+Jquery" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-twitter">
			<a href="http://twitter.com/home?status=How+to+add+onclick+values+to+a+list+in+Jquery+-+http://b2l.me/yqpg&amp;source=shareaholic" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://12stix.com/2009/04/07/how-to-add-onclick-values-to-a-list-in-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
