How to change image with mouse click?
-
using javascripts or DHTML can we change image with a mouse click? Actually i want to give some graphical effects to my images.
-
Answer:
Try this code and replace your images name with "bulbon.gif" and "bulboff.gif" <html> <head> <script type="text/javascript"> cc=0; function changeimage() { if (cc==0) { cc=1; document.getElementById('myimage').src="… } else { cc=0; document.getElementById('myimage').src="… } } </script> </head> <body> <img id="myimage" onclick="changeimage()" border="0" src="bulboff.gif" width="100" height="180" /> <p>Click to turn on/off the light</p> </body> </html>
x2 at Yahoo! Answers Visit the source
Other answers
Lots of examples and codes at following sites: http://www.dynamicdrive.com/dynamicindex15/index.html http://www.stunicholls.com/gallery/index.html Mouseovers are a lot better to change images as viewer doesn't have to click. Example: Mouseover - CSS <style type="text/css"> .banner { background: url('Image1.png') no-repeat center scroll; width: 128px; height: 131px; padding-top: 10%; } .banner:hover { background: url('image2.png') no-repeat center scroll; width: 128px; height: 131px; } a { color: #006800; font-weight: 900; font-size: 1em; } </style> <div class="banner"><a href="#" title="Mouseover Me">Mouseover Me</a></div> HTHs, Ron
Shadow Knows
Graphical effects - you mean to enlarge it? onclick="this.src='yourimage.jpg';this… You can specify a different source, it would also change the image, this is the easiest way.
Related Q & A:
- How To Set Image Generator?Best solution by wiki.openwrt.org
- How To Crop Image For Green Card Online?Best solution by youtube.com
- How to change thin image to fat image in iPhone SDK?Best solution by Stack Overflow
- How do you make homemade mouse ears?Best solution by quora.com
- How many nipples does a mouse have?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.