davc2018-07-05 15:06:55
davc, 2018-07-05 15:06:55

After changing css via JavaScript hover doesn't work, what should I do?

Hello, I have an element like this and there is css
<div id="elem"></div>

        height: 100px;
        width: 200px;
        background-color: green;
        background-color: blue;

The next question is: When using JavaScript to change the color of an element, after that hover does not work, and this does not only affect the color. When changing any property through javascript, css does not work correctly. What to do?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
antpv, 2018-07-05

If you want :hover to override your own styling, use !important in :hover .
For example:

        background-color: blue !important;

Stimulate, 2018-07-05


Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question