Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Onclick with image link

I want to create a menu that will change when mouseover and onclick.

But, my onclick will only turn blank when clicked.

I found out that if i delete the a href, the onclick function will function.

Anyone know how to solve the problem?

<a href="{storeurl}?act=aboutus">
  <img src="skins/sunlift/styleImages/navbar_pic/aboutus_n.jpg"
       onclick="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_h.jpg'"
       onmouseover="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_h.jpg'"
       onmouseout="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_n.jpg'"/>
</a>
like image 477
eric Avatar asked Dec 27 '22 16:12

eric


1 Answers

add return false; at the end of the callback function:

<a href="{storeurl}?act=aboutus"><img src="skins/sunlift/styleImages/navbar_pic/aboutus_n.jpg"
                                                               onclick="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_h.jpg'; return false;"
                                                               onmouseover="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_h.jpg'"
                                                               onmouseout="this.src='skins/sunlift/styleImages/navbar_pic/aboutus_n.jpg'"
                                                              /></a>
like image 160
gabitzish Avatar answered Dec 29 '22 08:12

gabitzish