Monday 15 March 2010

jquery - Selecting div in parent element -


I'm running into this issue due to a hilarious short memory loss ...

Trying to do slide-toggle is a div element that resides in the same basic element as the button.

There are many html productions on each loaded page, so the correct consistent goal is.

  & lt; Div class = "exBtn" & gt; & Lt; A href = "#" & gt; & Lt; Img src = "& lt ;? php echo get_template_directory_uri () ;? & gt; /media/showTextButton.png" & gt; & Lt; / A & gt; & Lt; / Div & gt; & Lt; Div class = "initialPostLoad" & gt; & Lt ;? Php the_content ('Read the rest of this entry & amp; raquo;'); ? & Gt; & Lt; / Div & gt; & Lt ;! - End initial post - & gt; $ (Document) .ready (function () {$ ('ExBtn a') Click (function) (Event) {event.preventDefault (); $ (this) .Parent (). Closest ('initialPostLoad') Slide Toggle ();});});    

  $ (this). Parent (). Closest ('initial.PostLoad') .slideToggle ();   

You do not want closest closest means "search among parents of this element" you want to search among brothers In fact, what you want to do is to get to the next brother. It is simple: just use next :

  $ (this). Parent (). Next () SlideToggle ();    

No comments:

Post a Comment