nevermind my last reply, eq() works great, I just forgot to change my code... here is the code snipet that works (for future reference)
jQuery.get("http://www.online-health-insurance.apollobackstage.com/ includes/seniorFreeQuoteBody.php", function(data){ $("body#seniors #text p:eq(2)").after(data); },"text"); On Jul 13, 2:11 pm, Matthew <mvbo...@gmail.com> wrote: > Ok, so eq() seems to work fine, I tried nth-child but im not sure if > it worked the way I wanted. When I console.log eq() for the code > snipet I provided i get "[p]" does that look right? > > Here is a DOM example from my page: > > <body id="seniors"> > ... > ... > <div id="text"> > <some divs and ul navigation> > <h1>..</h1> > <p>...</p> > <p>...</p> > <p>...</p> > </div> > ... > ... > </body> > > Here is my goal with eq(), Im trying to insert some data from a php > file after the desired paragraph: > > jQuery.get("http://www.online-health-insurance.apollobackstage.com/ > includes/seniorFreeQuoteBody.php", function(data){ > $("body#seniors #text > p:nth-child(2)").after(data); > }); > > On Jul 13, 12:22 pm, James <james.gp....@gmail.com> wrote: > > > The eq() selector is one way of doing it:http://docs.jquery.com/Selectors/eq > > > On Jul 13, 9:09 am, Matthew <mvbo...@gmail.com> wrote: > > > > So it seems like everyday I learn a new way to code the same thing. > > > What I am trying to do is add some code after a paragraph depending on > > > how many paragraphs are in the content. I'm not to worried about logic > > > right now justsyntax. Here is my code: > > > > My questions is regarding thissyntax: $("p", "body#seniors #text") > > > [2].append(something); > > > > Shouldn't that append something after the 3rd paragraph in the #text > > > div (if it exists)? > > > > If I have the wrongsyntax, how would I access the $("p", > > > "body#seniors #text") array at different indexes? > > > > Thanks, > > > Matthew