<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Questions and Answers from the List</title>
	<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list</link>
	<description>Getting to know the library of choice for unobtrusive JavaScript</description>
	<pubDate>Fri, 25 Jul 2008 03:36:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Karl Swedberg</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-49850</link>
		<dc:creator>Karl Swedberg</dc:creator>
		<pubDate>Tue, 24 Jun 2008 18:20:12 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-49850</guid>
		<description>Hi Jon,

In that case, you might want to use  &lt;code&gt;$('.poem-stanza &gt; div:nth-child(2)').addClass('blue_txt');&lt;/code&gt; 

Keep in mind that :nth-child(n) is 1-based, whereas all the other jQuery selectors are 0-based.

Hope that helps.</description>
		<content:encoded><![CDATA[<p>Hi Jon,</p>
<p>In that case, you might want to use  <code>$('.poem-stanza > div:nth-child(2)').addClass('blue_txt');</code> </p>
<p>Keep in mind that :nth-child(n) is 1-based, whereas all the other jQuery selectors are 0-based.</p>
<p>Hope that helps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-49478</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Tue, 17 Jun 2008 13:49:54 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-49478</guid>
		<description>In going through the 'Learning jQuery' book, I did some experimenting with the content of 'Chapter 1/alice.html'. Specifically, I have this selector and statement... 

$(document).ready(function() {
  $('.poem-stanza &#62; div:eq(1)').addClass('blue_txt');
});

The problem is that when this is applied only the FIRST INSTANCE of "second child div of class .poem-stanza" gets the new class. Please note that the alice.html file has TWO INSTANCES of '.poem-stanza &#62; div:eq(1)'. 

        
          YKCOWREBBAJ
          
            sevot yhtils eht dna ,gillirb sawT'
            ;ebaw eht ni elbmig dna eryg diD
            ,sevogorob eht erew ysmim llA
            .ebargtuo shtar emom eht dnA
          
        
        She puzzled over this for some time, but at last a bright thought struck her. "Why, it's a Looking-glass book, of course! And if I hold it up to a glass, the words will all go the right way again."
        This was the poem that Alice read.
        
          JABBERWOCKY
          
            'Twas brillig, and the slithy toves
            Did gyre and gimble in the wabe;
            All mimsy were the borogoves,
            And the mome raths outgrabe.
          
        

QUESTION: Why does the 2nd instance get ignored (unprocessed)? How do I modify my statement so that the 2nd instance DOES get processed?

THANKS!

Jon</description>
		<content:encoded><![CDATA[<p>In going through the &#8216;Learning jQuery&#8217; book, I did some experimenting with the content of &#8216;Chapter 1/alice.html&#8217;. Specifically, I have this selector and statement&#8230; </p>
<p>$(document).ready(function() {<br />
  $(&#8217;.poem-stanza &gt; div:eq(1)&#8217;).addClass(&#8217;blue_txt&#8217;);<br />
});</p>
<p>The problem is that when this is applied only the FIRST INSTANCE of &#8220;second child div of class .poem-stanza&#8221; gets the new class. Please note that the alice.html file has TWO INSTANCES of &#8216;.poem-stanza &gt; div:eq(1)&#8217;. </p>
<p>          YKCOWREBBAJ</p>
<p>            sevot yhtils eht dna ,gillirb sawT&#8217;<br />
            ;ebaw eht ni elbmig dna eryg diD<br />
            ,sevogorob eht erew ysmim llA<br />
            .ebargtuo shtar emom eht dnA</p>
<p>        She puzzled over this for some time, but at last a bright thought struck her. &#8220;Why, it&#8217;s a Looking-glass book, of course! And if I hold it up to a glass, the words will all go the right way again.&#8221;<br />
        This was the poem that Alice read.</p>
<p>          JABBERWOCKY</p>
<p>            &#8216;Twas brillig, and the slithy toves<br />
            Did gyre and gimble in the wabe;<br />
            All mimsy were the borogoves,<br />
            And the mome raths outgrabe.</p>
<p>QUESTION: Why does the 2nd instance get ignored (unprocessed)? How do I modify my statement so that the 2nd instance DOES get processed?</p>
<p>THANKS!</p>
<p>Jon</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: josedelaranda</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-45199</link>
		<dc:creator>josedelaranda</dc:creator>
		<pubDate>Sun, 04 May 2008 14:30:50 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-45199</guid>
		<description>Thanks for your code. Cheers from Peru</description>
		<content:encoded><![CDATA[<p>Thanks for your code. Cheers from Peru</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pablo</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-39759</link>
		<dc:creator>pablo</dc:creator>
		<pubDate>Sat, 12 Apr 2008 21:24:25 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-39759</guid>
		<description>Hi Karl, everything is fine, it was basically an internet provider issue, sorry about te delay in replying...was out of town

thanks again for the help

hope all is well

P</description>
		<content:encoded><![CDATA[<p>Hi Karl, everything is fine, it was basically an internet provider issue, sorry about te delay in replying&#8230;was out of town</p>
<p>thanks again for the help</p>
<p>hope all is well</p>
<p>P</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-39428</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Thu, 10 Apr 2008 03:32:34 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-39428</guid>
		<description>Hi Pablo,
Do you have a page somewhere that I can look at? It will help me to troubleshoot for you if I can see what you're doing.</description>
		<content:encoded><![CDATA[<p>Hi Pablo,<br />
Do you have a page somewhere that I can look at? It will help me to troubleshoot for you if I can see what you&#8217;re doing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pablo</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-39406</link>
		<dc:creator>pablo</dc:creator>
		<pubDate>Wed, 09 Apr 2008 21:48:22 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-39406</guid>
		<description>Hey karl, I noticed it doesn't work in ie6, works liek a charm in all the other browsers.

Thanks

pablo</description>
		<content:encoded><![CDATA[<p>Hey karl, I noticed it doesn&#8217;t work in ie6, works liek a charm in all the other browsers.</p>
<p>Thanks</p>
<p>pablo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pablo</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-36422</link>
		<dc:creator>pablo</dc:creator>
		<pubDate>Wed, 02 Apr 2008 16:47:03 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-36422</guid>
		<description>Thank you very much Karl, I really appreciate it

pablo</description>
		<content:encoded><![CDATA[<p>Thank you very much Karl, I really appreciate it</p>
<p>pablo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Karl</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-35327</link>
		<dc:creator>Karl</dc:creator>
		<pubDate>Sat, 29 Mar 2008 22:02:39 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-35327</guid>
		<description>Hi Pablo,

The .next() method only selects the &lt;em&gt;immediate&lt;/em&gt; next sibling. If all your h2 and p elements are siblings, you might need to use the nextUntil plugin:

&lt;pre&gt;&lt;code&gt;$.fn.nextUntil = function(expr) {
   var match = [];

   // We need to figure out which elements to push onto the array
   this.each(function(){
       // Traverse through the sibling nodes
       for( var i = this.nextSibling; i; i = i.nextSibling ) {
           // Make sure that we're only dealing with elements
           if ( i.nodeType != 1 ) continue;

           // If we find a match then we need to stop
           if ( jQuery.filter( expr, [i] ).r.length ) break;

           // Otherwise, add it on to the stack
           match.push( i );
       }
   });

   return this.pushStack( match, arguments );
};&lt;/code&gt;&lt;/pre&gt;

Then you could do this:

&lt;pre&gt;&lt;code&gt;  $(document).ready(function(){

  	$('.accordion h2:first').addClass('active');
  	$('.accordion h2:eq(1)').nextAll('p').hide();

  	$(".accordion h2").click(function(){
      var $theseParas = $(this).nextUntil('h2').slideToggle('slow');
      
    	$(this).toggleClass('active')
    	  .siblings("h2").removeClass('active').end()
        .siblings('p').not($theseParas).slideUp('slow');
  	});

  });&lt;/code&gt;&lt;/pre&gt;

A  couple things: If you know the tag name of the element with class "accordion," you should probably use it in the selector. For example, "div.accordion" instead of just ".accordion." Also, you'll probably be better off if you wrap each group of paragraphs in its own div. It's easier to select a single div (no need for the nextUntil plugin) and the animation will be smoother.</description>
		<content:encoded><![CDATA[<p>Hi Pablo,</p>
<p>The .next() method only selects the <em>immediate</em> next sibling. If all your h2 and p elements are siblings, you might need to use the nextUntil plugin:</p>
<pre><code>$.fn.nextUntil = function(expr) {
   var match = [];

   // We need to figure out which elements to push onto the array
   this.each(function(){
       // Traverse through the sibling nodes
       for( var i = this.nextSibling; i; i = i.nextSibling ) {
           // Make sure that we're only dealing with elements
           if ( i.nodeType != 1 ) continue;

           // If we find a match then we need to stop
           if ( jQuery.filter( expr, [i] ).r.length ) break;

           // Otherwise, add it on to the stack
           match.push( i );
       }
   });

   return this.pushStack( match, arguments );
};</code></pre>
<p>Then you could do this:</p>
<pre><code>  $(document).ready(function(){

  	$('.accordion h2:first').addClass('active');
  	$('.accordion h2:eq(1)').nextAll('p').hide();

  	$(".accordion h2").click(function(){
      var $theseParas = $(this).nextUntil('h2').slideToggle('slow');

    	$(this).toggleClass('active')
    	  .siblings("h2").removeClass('active').end()
        .siblings('p').not($theseParas).slideUp('slow');
  	});

  });</code></pre>
<p>A  couple things: If you know the tag name of the element with class &#8220;accordion,&#8221; you should probably use it in the selector. For example, &#8220;div.accordion&#8221; instead of just &#8220;.accordion.&#8221; Also, you&#8217;ll probably be better off if you wrap each group of paragraphs in its own div. It&#8217;s easier to select a single div (no need for the nextUntil plugin) and the animation will be smoother.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pablo</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-35234</link>
		<dc:creator>pablo</dc:creator>
		<pubDate>Sat, 29 Mar 2008 06:50:58 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-35234</guid>
		<description>hi,
I'm trying to figure out how to make this work with more then one paragraph,
basically the second paragraph doesn't appear, i tried different combination that made it appear but once i closed the h2 and re-opened it the second paragraph would not show, i even had the same problem with a paragraph containing a floated image. the image came back but not the paragraph,

if anyone could help me out, that would be great.



thanks.


HTML
&lt;code&gt;

        Latest Updates..
                       
                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam leo. Fusce pharetra risus eu tellus. Ut turpis. Nunc congue lacinia dolor. Vivamus ipsum quam, egestas ac, luctus at, aliquam a, est. Donec fermentum enim id magna. Duis nisi orci, feugiat eget, imperdiet eu, condimentum id, leo. Donec cursus. Vivamus gravida nibh vitae dolor. Sed mattis. Pellentesque ante magna, egestas vel, pharetra in, vulputate ut, est. Quisque felis risus, iaculis in, blandit id, lobortis vel, purus.
               
                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam leo. Fusce pharetra risus eu tellus. Ut turpis. Nunc congue lacinia dolor. Vivamus ipsum quam, egestas ac, luctus at, aliquam a, est. Donec fermentum enim id magna. Duis nisi orci, feugiat eget, imperdiet eu, condimentum id, leo. Donec cursus. Vivamus gravida nibh vitae dolor. Sed mattis. Pellentesque ante magna, egestas vel, pharetra in, vulputate ut, est. Quisque felis risus, iaculis in, blandit id, lobortis vel, purus.&lt;/a&gt;.
               
               header
                       
                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam leo. Fusce pharetra risus eu tellus. Ut turpis. Nunc congue lacinia dolor. Vivamus ipsum quam, egestas ac, luctus at, aliquam a, est. Donec fermentum enim id magna. Duis nisi orci, feugiat eget, imperdiet eu, condimentum id, leo. Donec cursus. Vivamus gravida nibh vitae dolor. Sed mattis. Pellentesque ante magna, egestas vel, pharetra in, vulputate ut, est. Quisque felis risus, iaculis in, blandit id, lobortis vel, purus.
            
&lt;/code&gt;

JQUERY

&lt;pre&gt;&lt;code&gt;$(document).ready(function(){

	$(".accordion h2:first").addClass("active");
	$(".accordion p:not(:first)").hide();

	$(".accordion h2").click(function(){

	  $(this).next("p").slideToggle("slow")
	  .siblings("p:visible").slideUp("slow");
	  $(this).toggleClass("active");
	  $(this).siblings("h2").removeClass("active");

	});

}); 
&lt;/code&gt;&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>hi,<br />
I&#8217;m trying to figure out how to make this work with more then one paragraph,<br />
basically the second paragraph doesn&#8217;t appear, i tried different combination that made it appear but once i closed the h2 and re-opened it the second paragraph would not show, i even had the same problem with a paragraph containing a floated image. the image came back but not the paragraph,</p>
<p>if anyone could help me out, that would be great.</p>
<p>thanks.</p>
<p>HTML<br />
<code></p>
<p>        Latest Updates..</p>
<p>                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam leo. Fusce pharetra risus eu tellus. Ut turpis. Nunc congue lacinia dolor. Vivamus ipsum quam, egestas ac, luctus at, aliquam a, est. Donec fermentum enim id magna. Duis nisi orci, feugiat eget, imperdiet eu, condimentum id, leo. Donec cursus. Vivamus gravida nibh vitae dolor. Sed mattis. Pellentesque ante magna, egestas vel, pharetra in, vulputate ut, est. Quisque felis risus, iaculis in, blandit id, lobortis vel, purus.</p>
<p>                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam leo. Fusce pharetra risus eu tellus. Ut turpis. Nunc congue lacinia dolor. Vivamus ipsum quam, egestas ac, luctus at, aliquam a, est. Donec fermentum enim id magna. Duis nisi orci, feugiat eget, imperdiet eu, condimentum id, leo. Donec cursus. Vivamus gravida nibh vitae dolor. Sed mattis. Pellentesque ante magna, egestas vel, pharetra in, vulputate ut, est. Quisque felis risus, iaculis in, blandit id, lobortis vel, purus..</p>
<p>               header</p>
<p>                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam leo. Fusce pharetra risus eu tellus. Ut turpis. Nunc congue lacinia dolor. Vivamus ipsum quam, egestas ac, luctus at, aliquam a, est. Donec fermentum enim id magna. Duis nisi orci, feugiat eget, imperdiet eu, condimentum id, leo. Donec cursus. Vivamus gravida nibh vitae dolor. Sed mattis. Pellentesque ante magna, egestas vel, pharetra in, vulputate ut, est. Quisque felis risus, iaculis in, blandit id, lobortis vel, purus.</p>
<p></code></p>
<p>JQUERY</p>
<pre><code>$(document).ready(function(){

	$(".accordion h2:first").addClass("active");
	$(".accordion p:not(:first)").hide();

	$(".accordion h2").click(function(){

	  $(this).next("p").slideToggle("slow")
	  .siblings("p:visible").slideUp("slow");
	  $(this).toggleClass("active");
	  $(this).siblings("h2").removeClass("active");

	});

});
</code></pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: çeviri</title>
		<link>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-33290</link>
		<dc:creator>çeviri</dc:creator>
		<pubDate>Sun, 09 Mar 2008 19:08:56 +0000</pubDate>
		<guid>http://www.learningjquery.com/2007/12/questions-and-answers-from-the-list#comment-33290</guid>
		<description>thanks for codes</description>
		<content:encoded><![CDATA[<p>thanks for codes</p>
]]></content:encoded>
	</item>
</channel>
</rss>
