How to make a button change on mouseover in html

1.3k views Asked by At

I am new to using javascript in HTML and I want to make a simple on mouseover script that changes the image on a button. All I need is a javascript code that will fit between 2 script tags and a HTML code that references to the code between the script tags.

1

There are 1 answers

0
Anish Sharma On

I would suggest using CSS and not JavaScript. Using JavaScript would be ugly and waste of time. Using CSS its fast and easy. This could be a small CSS code of what you require.

.image-btn {
    background-image: url("button-image-name.jpg");
}

.image-btn:hover {
    background-image: url("button-image-name-on-hover.jpg");
}