Bless youuuu :)

Very true, it didn't help me to understand :contains, but it makes
things so much simpler.
I just changed the if condition and everything works!

I am impressed you understood what I wanted :)

Thanks a lot!!!


On Jan 13, 6:00 pm, Nathan Klatt <n8kl...@gmail.com> wrote:
> On Wed, Jan 13, 2010 at 10:54 AM, happysmile <francesca.manc...@gmail.com>
> wrote:
>
> > It works only the first time you click on the button (changes from
> > 'show' to 'hide'), while it remains almost always 'Hide' in all the
> > following clicks.
>
> This won't help you understand :contains but I think it does what you want:
>
> http://jsbin.com/udesu/edit
>
> Assuming this markup:
> <p>
>   <button class="show_profile">Show details</button>
>   <span class="directors_details" style="display:none">
>     <br />details details details</span></p>
>
> The code:
> $('.show_profile').click(function() {
>
>   // toggle link class to change the arrow background image
>   var jThis = $(this)
>     .toggleClass("hide_profile");
>
>   // toggle visibility profile
>   var jDetails = jThis.next('.directors_details')
>     .toggle();
>
>   // change show/hide text in the link
>   if (jDetails.is(":visible")) {
>     jThis.text(jThis.text().replace('Show','Hide'));
>   } else {
>     jThis.text(jThis.text().replace('Hide','Show'));
>   }
>
>   return false;
>
> });
>
> Nathan

Reply via email to