0

I create an element like: var btn = document.createElement("BUTTON");

Then I append it to the DOM like: document.getElementsByClassName("text")[0].appendChild(btn);

I want to change the onHover property for the button. I want to achieve something like:

btn.style.onHover ="background: #3cb0fd";

OR

btn.style.backgroundColor.onHover ="#3cb0fd";

I am not sure what's the right code for this.

3
  • 1
    I'd say use CSS. button:hover { background: #something; } or JS events onmouseenter and onmouseleave. Commented Nov 18, 2015 at 10:47
  • Here is an answer stackoverflow.com/a/11371599/616535 Commented Nov 18, 2015 at 10:48
  • use css its more simpler. Commented Nov 18, 2015 at 10:48

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.