Image toggle

Discussion in 'Scripts' started by S3vEn, Mar 28, 2009.

  1. #1
    I was wondering if anyone knew how to toggle a image (when you click on it)

    For example

    >

    if i click on it

    <

    and when i click on it again

    >

    I was to toggle a image/button in my sidebar which use jquery to hide/show chat.

    i want to grayscale the image and when click on lights up.

    sorry if I couldn't explain properly,

    please and thanks

    Jimmy
     
    S3vEn, Mar 28, 2009 IP
  2. deemainer

    deemainer Active Member

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #2
    you can do it with java...try this:

    <a href="somewhere.html"
    onmouseover="document.sub_but.src='image2.gif'"
    onmouseout="document.sub_but.src='image1.gif'">

    <img src="image1.gif" width="100" height="100" border="0"
    alt="Move your mouse over me" name="sub_but" />
    </a>


    good luck !
     
    deemainer, Mar 28, 2009 IP
  3. deemainer

    deemainer Active Member

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #3
    edited as a double posting for some reason...sorry
     
    deemainer, Mar 28, 2009 IP
  4. S3vEn

    S3vEn Active Member

    Messages:
    212
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #4
    Isn't that just a image rollover? So it doesn't stay the same after toggle.

    For example

    OFF

    Click

    ON

    Click

    OFF

    Basically I want toggle function with images not rollover, correct my if I am wrong about the code above

    Please and thank
     
    S3vEn, Mar 28, 2009 IP
  5. deemainer

    deemainer Active Member

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #5
    aah....ok...see what your saying

    I guess you could change
    to
    onmouseout="document.sub_but.src='image2.gif'">

    This would mean the image would stay as image 2 on mouseout. But then i guess it would only toggle once and not change again after first toggle until page refresh.

    Not sure then.If you find out let me know !
     
    deemainer, Mar 29, 2009 IP
  6. deemainer

    deemainer Active Member

    Messages:
    351
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    78
    #6
    ok.did a bit of digging.Try this. I think its what your after:


     
    deemainer, Mar 29, 2009 IP
    S3vEn likes this.
  7. S3vEn

    S3vEn Active Member

    Messages:
    212
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #7
    Ummm I put this in the css?, Thanks deemainer you been great help. I gonna give it a try in a bit, currently trying to get some other function working.
     
    S3vEn, Mar 29, 2009 IP