Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2010
    Thanked 0 Times in 0 Posts

    Javascript Button Change

    Hello all.

    I have the following HTML code, that creates a button.

    <input name="" type="image" src="../images/click.jpg" id="clicky" class="btn">
    This button is using a graphic, of a plus sign.

    I am then using the following Javascript

    var s = $('#slide'), w = $(s.find('span')[0]).width();
    s.css({width: 0, overflow: 'hidden', whiteSpace: 'nowrap'});
    s.stop().animate({width: w}, {duration: 'slow', queue: false});
    }, function(){
    s.stop(true).animate({width: 0}, {duration: 'slow', queue: false, complete: function(){s.hide();}});
    The javascript pushes a DIV out and in, ie makes it expand and then hides it again when clicked a second time.

    Now my problem is, i would like the image of the button to change, when the button has been clicked and the DIV has been expanded. I would like to change the image to a minus ( - ). And then when the button is clicked again to hide the div, i would like to change the image back to a plus (+)

    Im a bit stuck thou, can anyone help please?

  2. #2
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Bucharest, ROMANIA
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by davidhopkins View Post
    I am then using the following Javascript
    You are using the following what? Whenever you use a library/framework, make sure you tell us which is that library. We can not guess. The problem is that frameworks use custom methods and functions, so that we have not the slightest idea what lays behind them. So, what is that? JQuery? Prototype? MooTools? Other?
    Edit: I have moved your Thread into the JavaScript Frameworks Forum, the place where it should be created from the beginning
    Last edited by Kor; 06-01-2010 at 06:34 PM.
    Offshore programming


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts