[jQuery] Re: jQuery syntax question

2009-07-14 Thread Matthew
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

[jQuery] Re: jQuery syntax question

2009-07-13 Thread Matt Zagrabelny
On Mon, 2009-07-13 at 12:09 -0700, Matthew 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 just syntax. Here is my

[jQuery] Re: jQuery syntax question

2009-07-13 Thread MorningZ
$(p, body#seniors #text)[2]. does not mean third paragraph nth-child would be what you could use http://docs.jquery.com/Selectors/nthChild#index On Jul 13, 3:09 pm, 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

[jQuery] Re: jQuery syntax question

2009-07-13 Thread James
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

[jQuery] Re: jQuery syntax question

2009-07-13 Thread Matthew
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

[jQuery] Re: jQuery syntax question

2009-07-13 Thread Matthew
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){

[jQuery] Re: jQuery syntax question

2009-07-13 Thread Ricardo
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