javascript - Change the image of a JSF commandbutton with DHTML event onmouseover -


I want to change the image of my button when the mouse goes over it.

I can do this for DHTV Event OnMoverOver, but how?

Do I still need to make javascript for this?

What should I do to make this work?

This is my current code:

  & lt; H: commandButton class = "btn" image = "/ resources / images / mainbtn1.png" onmouseover = "/ resources / images / Mainbtn2.png" / "& gt;    < P> 

this & lt; h: commandButton Image = "foo.png" & gt; one HTML Lt; input type = "image" src = "foo.png" & gt; . onmouseover attribute (such as all the * as attributes ) Javascript should point to the functions, however, you are putting image path in there area. This only causes a javascript error (which you may have seen if

You have to write some JS which changes src E the attribute of the image button accordingly:

 < Do not forget to add code> onmouseover = "this.src = '/ resources / images / mainbtn2.png'"   

don '' onmouseout which changes the image back


Impossible In a solid problem, use the general practice CSS background, for this, the picture is HTML & lt; Input type = "picture" & gt; Technology is a completely different purpose, it represents an image map that allows you to send coordinates of the mouse where you clicked in the image map. You obviously are not interested in this information because you are not using a static image.

Example

  & lt; H: value of the command button = "" style class = "mybutton" />   

which generates

  & lt; Input type = "submit" value = "" class = "mybutton" />   

and add this CSS (kickoff example)

  .mybutton {margin: 2px; Padding: 0; Border: 0; Width: 100px; Height: 20px; Background-image: url ('foo.png'); Cursor: indicator; Overflow: visible; } .mybutton: hover {background-image: url ('bar.png'); }   

This is not only good reusable / maintainable, but also does not require JS support.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -