Marco, you don't need the end() in that statement you posted, that's
meant to return the object to it's previous state after you do
traversing/filtering on it.

A condensed version:

$("form a.option").click(function() {
   var $input = $("form input.fileimage"),
        visible = $input.is('visible');

   $input[ visible ? 'slideDown' : 'slideUp' ]('slow');
   $(this).text( visible ? 'I do'  : 'I don't' );

}

On Mar 30, 4:50 pm, James <james.gp....@gmail.com> wrote:
> Maybe something along the lines of:
>
> $("form a.option").click(function() {
>      var $input = $("form input.fileimage");
>      if ( $("form input.fileimage").is(":visible") ) {
>           $input.slideUp"slow");
>           $(this).text("I want to...");
>      }
>      else {
>           $input.slideDown("slow");
>           $(this).text("I don't want to...");
>      }
>
> }
>
> On Mar 30, 9:44 am, M4rc0 <maluc...@gmail.com> wrote:
>
> > Hi there!
>
> > Please bare with me if this question is too basic :)
>
> > I have the following code:
>
> > $(function(){
> >                         $("form a.option").click(function(){
> >                                 $("form 
> > input.fileimage:visible").slideUp("slow");
> >                                 $("form 
> > input.fileimage:hidden").slideDown("slow");
> >                         });
> >                 });
>
> > I have an input with the class .fileimage and a link saying "I don't
> > want to upload an image now"
>
> > It works good. Now there's something I would like to do but that I
> > don't know how to.
>
> > When I click the anchor, I would like to change the text as well.
> > So when the input is there (visible) it stays normal, but when I click
> > to hide it should say "I want to upload an image now" instead.
>
> > I'm trying with $("form a.option").text("new text").end();
> > But I don't know where to put that, and once it changes the text it
> > doesn't change back to "I don't want..." when the input is visible.
>
> > Can somebody point me out in the right direction here?

Reply via email to