<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Writing multiple toggle links in JQuery</title>
	<atom:link href="http://www.olliekav.com/web-design/writing-multiple-toggle-links-in-jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://www.olliekav.com/web-design/writing-multiple-toggle-links-in-jquery</link>
	<description>Designer, Illustrator, DJ and all round genuine bloke...</description>
	<lastBuildDate>Thu, 22 Jul 2010 21:16:32 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: Lee</title>
		<link>http://www.olliekav.com/web-design/writing-multiple-toggle-links-in-jquery/comment-page-1#comment-1112</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Thu, 22 Jul 2010 21:16:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.olliekav.com/?p=127#comment-1112</guid>
		<description>Delete the above post and this one then, you need to make it clear to people that:

toggle-item- on each thing they would like to show and hide, should be set to, lets say: toggle-item-link1.

So in other words make sure each &quot;toggle-item-&quot; your hiding and showing has a name of:

&quot;toggle-item-link1&quot;

The &quot;link1&quot; needs to match the class=&quot;link1&quot; that called it, so dont just use &quot;toggle-item&quot; and/or &quot;toggle-item-&quot; because that wont work.

Got it ?!?</description>
		<content:encoded><![CDATA[<p>Delete the above post and this one then, you need to make it clear to people that:</p>
<p>toggle-item- on each thing they would like to show and hide, should be set to, lets say: toggle-item-link1.</p>
<p>So in other words make sure each &#8220;toggle-item-&#8221; your hiding and showing has a name of:</p>
<p>&#8220;toggle-item-link1&#8243;</p>
<p>The &#8220;link1&#8243; needs to match the class=&#8221;link1&#8243; that called it, so dont just use &#8220;toggle-item&#8221; and/or &#8220;toggle-item-&#8221; because that wont work.</p>
<p>Got it ?!?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.olliekav.com/web-design/writing-multiple-toggle-links-in-jquery/comment-page-1#comment-1110</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Thu, 22 Jul 2010 19:41:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.olliekav.com/?p=127#comment-1110</guid>
		<description>Just wanted to say thank you for this &quot;tut&quot;, i was the same as the user above, could not find what i was looking for/to do. Then i did another google only to find this page and BINGO! just what i wanted to do...

What i had been doing was just like you said above:
&quot;But what about if we want to do this for multiple items on the page and not call each item on its own and create a bunch of unnecessary code&quot;

&quot;bunch of unnecessary code&quot;:


$(document).ready(function(){
$(&quot;#open1&quot;).click(function(event){
$(&quot;#block1&quot;).slideFadeToggle(&quot;slow&quot;);
event.preventDefault();
});
$(&quot;#close1&quot;).click(function(event){
$(&quot;#block1&quot;).slideFadeToggle(&quot;slow&quot;);
event.preventDefault(); });
$(&quot;#open3&quot;).click(function(event){
$(&quot;#block3&quot;).slideFadeToggle(&quot;slow&quot;);
event.preventDefault(); });
$(&quot;#close3&quot;).click(function(event){
$(&quot;#block3&quot;).slideFadeToggle(&quot;slow&quot;);
event.preventDefault(); }); });


So yea my code was/is so not the way to do it, sure it works and gets the job done but not when you think about what jQuery was intended for. &quot;Wright Less, Do More&quot;

So thanks dude, im off to code this into my site !</description>
		<content:encoded><![CDATA[<p>Just wanted to say thank you for this &#8220;tut&#8221;, i was the same as the user above, could not find what i was looking for/to do. Then i did another google only to find this page and BINGO! just what i wanted to do&#8230;</p>
<p>What i had been doing was just like you said above:<br />
&#8220;But what about if we want to do this for multiple items on the page and not call each item on its own and create a bunch of unnecessary code&#8221;</p>
<p>&#8220;bunch of unnecessary code&#8221;:</p>
<p>$(document).ready(function(){<br />
$(&#8220;#open1&#8243;).click(function(event){<br />
$(&#8220;#block1&#8243;).slideFadeToggle(&#8220;slow&#8221;);<br />
event.preventDefault();<br />
});<br />
$(&#8220;#close1&#8243;).click(function(event){<br />
$(&#8220;#block1&#8243;).slideFadeToggle(&#8220;slow&#8221;);<br />
event.preventDefault(); });<br />
$(&#8220;#open3&#8243;).click(function(event){<br />
$(&#8220;#block3&#8243;).slideFadeToggle(&#8220;slow&#8221;);<br />
event.preventDefault(); });<br />
$(&#8220;#close3&#8243;).click(function(event){<br />
$(&#8220;#block3&#8243;).slideFadeToggle(&#8220;slow&#8221;);<br />
event.preventDefault(); }); });</p>
<p>So yea my code was/is so not the way to do it, sure it works and gets the job done but not when you think about what jQuery was intended for. &#8220;Wright Less, Do More&#8221;</p>
<p>So thanks dude, im off to code this into my site !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lee</title>
		<link>http://www.olliekav.com/web-design/writing-multiple-toggle-links-in-jquery/comment-page-1#comment-1104</link>
		<dc:creator>Lee</dc:creator>
		<pubDate>Thu, 15 Apr 2010 21:52:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.olliekav.com/?p=127#comment-1104</guid>
		<description>Spent days researching show/hide to find the best method and you have it by a mile. A HUGE thank you to you.</description>
		<content:encoded><![CDATA[<p>Spent days researching show/hide to find the best method and you have it by a mile. A HUGE thank you to you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: links for 2010-03-02 &#124; Folks Pants</title>
		<link>http://www.olliekav.com/web-design/writing-multiple-toggle-links-in-jquery/comment-page-1#comment-1103</link>
		<dc:creator>links for 2010-03-02 &#124; Folks Pants</dc:creator>
		<pubDate>Thu, 08 Apr 2010 17:21:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.olliekav.com/?p=127#comment-1103</guid>
		<description>[...] Writing multiple toggle links in JQuery – olliekav.com (tags: jquery toggle) [...]</description>
		<content:encoded><![CDATA[<p>[...] Writing multiple toggle links in JQuery – olliekav.com (tags: jquery toggle) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ah.</title>
		<link>http://www.olliekav.com/web-design/writing-multiple-toggle-links-in-jquery/comment-page-1#comment-1102</link>
		<dc:creator>ah.</dc:creator>
		<pubDate>Sat, 27 Mar 2010 17:14:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.olliekav.com/?p=127#comment-1102</guid>
		<description>This code is terrific. I&#039;ve implemented it with some success, but have one problem. Using multiple links and multiple divs, the toggle function will turn on each individual div, but it will not close whichever div is currently open. I solved this by adding a hide function to the onclick event and all is well except when you click the same link that is already open. Doing this merely hides and shows the said div rather than reversing its toggle state.

So is there a way to build in an if/than function that checks for this and corrects? My code is below:

&lt;code&gt;
		/* JQUERY SMOOTH HIDE/DISPLAY CONTENT ONCLICK */
		$(document).ready(function() {
		 // hides the ribbon as soon as the DOM is ready
		 // (a little sooner than page load)
		$(&#039;div[class^=ribbon-]&#039;).hide();
		 // loop through links and build function
		$(&#039;a[class^=link]&#039;).click(function() {
			$(&#039;div[class^=ribbon-]&#039;).hide(&#039;fast&#039;);
		   	var $this = $(this);
			var x = $this.attr(&quot;className&quot;);
			$(&#039;.ribbon-&#039; + x).toggle(400);
			return false;
			});
		});
&lt;/code&gt;

And the HTML: 

&lt;code&gt;
	
		
		
		&lt;a href=&quot;index.html&quot; rel=&quot;nofollow&quot;&gt;Home&lt;/a&gt;
		&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt;Projects&lt;/a&gt;
		&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt;Videos&lt;/a&gt;
		&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt;Archives&lt;/a&gt;
		&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt;Editors&lt;/a&gt;
		
		
		
			PROJECTS
			VIDEOS
			ARCHIVES
			
			&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt;&lt;/a&gt;
			&lt;a href=&quot;#&quot; rel=&quot;nofollow&quot;&gt;&lt;/a&gt;
			
		
		
	
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>This code is terrific. I&#8217;ve implemented it with some success, but have one problem. Using multiple links and multiple divs, the toggle function will turn on each individual div, but it will not close whichever div is currently open. I solved this by adding a hide function to the onclick event and all is well except when you click the same link that is already open. Doing this merely hides and shows the said div rather than reversing its toggle state.</p>
<p>So is there a way to build in an if/than function that checks for this and corrects? My code is below:</p>
<p><code><br />
		/* JQUERY SMOOTH HIDE/DISPLAY CONTENT ONCLICK */<br />
		$(document).ready(function() {<br />
		 // hides the ribbon as soon as the DOM is ready<br />
		 // (a little sooner than page load)<br />
		$('div[class^=ribbon-]').hide();<br />
		 // loop through links and build function<br />
		$('a[class^=link]').click(function() {<br />
			$('div[class^=ribbon-]').hide('fast');<br />
		   	var $this = $(this);<br />
			var x = $this.attr("className");<br />
			$('.ribbon-' + x).toggle(400);<br />
			return false;<br />
			});<br />
		});<br />
</code></p>
<p>And the HTML: </p>
<p><code></p>
<p>		<a href="index.html" rel="nofollow">Home</a><br />
		<a href="#" rel="nofollow">Projects</a><br />
		<a href="#" rel="nofollow">Videos</a><br />
		<a href="#" rel="nofollow">Archives</a><br />
		<a href="#" rel="nofollow">Editors</a></p>
<p>			PROJECTS<br />
			VIDEOS<br />
			ARCHIVES</p>
<p>			<a href="#" rel="nofollow"></a><br />
			<a href="#" rel="nofollow"></a></p>
<p></code></p>
]]></content:encoded>
	</item>
</channel>
</rss>
