Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Button Image Disappears onmouseout?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the following code-

<a style="align: center; border-style: none;" href="http://"; style="color: #000000"
onmouseover="document.getElementById('pic1').src='http://image_b.png'; this.style.color='#0ebfe9'"
onmouseout="document.getElementById('pic1').src='http://image_a.png'; this.style.color='#000000'">
<img src="http:/image_a.png" id="pic1">Event</a>

Unfortunately, my image button disappears after it is clicked (or pressed in a mobile setting) and as the new page is loading. I'm not sure what I may be missing here. Thank you for any ideas on this.

- David
 
author
Posts: 297
5
Android Firefox Browser Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you messing around with onmouseover and onmouseout at all instead of just using CSS :hover?

To answer your question: you probably have an issue that the mouseover and mouseout events will fire as the mouse pointer enters and leaves the image element as well as when it enters and leaves the anchor (because of event bubbling), you don't seem to have accounted for this at all.
 
Hot dog! An advertiser loves us THIS much:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
    Bookmark Topic Watch Topic
  • New Topic