Hi Ricardo, thanks for the clarification, i thought I rememberd seeing
the $( $(x)[2] ) syntax somewhere. I like that better than the eq().
My ID's are all good, I just needed the 'body#seniors #text' so only
pages in my senior section would be altered, but I guess doing a php
if/else would have been better since my pages are php.

On Jul 13, 4:06 pm, Ricardo <ricardob...@gmail.com> wrote:
> Well, $( $(x)[2] ) is exactly the same as $(x).eq(2), and eq() is way
> slower cause it needs to preserve the object and stuff. The point
> everyone missed is that $(x)[2] gives you a DOM element, not a jQuery
> object, that's why you need to "rewrap" it in jQuery.
>
> Also, IDs should be unique (only one #text element), so you can
> simplify your selector to $( $('#text p')[2] ).after(data) or $('#text
> p').eq(2).after(data);
>
> cheers,
> -- ricardo
>
> On Jul 13, 6:26 pm, Matthew <mvbo...@gmail.com> wrote:
>
> > 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

Reply via email to