0

change image of the button

asked 2018-04-12 09:31:13 +0800

elanyerth gravatar image elanyerth
13 2

I'm trying to change the image of the button every time I click on it. but I do not know what I'm doing wrong. this is my code

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-04-12 09:31:45 +0800

elanyerth gravatar image elanyerth
13 2
 <button id="botonlike" image="/imagen/likecora.png" style="background:white" label="" onClick="">
        <attribute name="onClick"><![CDATA[ 
        if(botonlike.getimage()=="/imagen/likecora.png")
      botonlike.setImage("/imagen/likerojo.png");
        else
       botonlike.setImage("/imagen/likecora.png");

      ]]>
        </attribute>
     </button>
link publish delete flag offensive edit

Comments

botonlike.getimage => it should be botonlike.getImage for javascript debugging, please use your console in the browser. You can see faults popping up there. Also inspect your element to see what attributes your button has, like that you can check if the imagesrc is changed or not.

chillworld ( 2018-04-12 13:20:12 +0800 )edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2018-04-12 09:31:13 +0800

Seen: 10 times

Last updated: Apr 12 '18

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More