-2

I want to add hover effect to the button​ like when I hover it its change the background color to #63A244 and the text color to white - #FFFFFF . Thanks in advance.

window.addEventListener("load", function() {
  window.cookieconsent.initialise({
    "palette": {
      "popup": {
        "background": "#ffffff",
        "text": "#63a244"
      },
      "button": {
        "background": "transparent",
        "text": "#63a244",
        "border": "#63a244"
      }
    },
    "position": "top",
    "content": {
      "message": "Cookies Massage",
      "dismiss": "OK",
      "link": "Read More",
      "href": "#"
    }
  })
});
<script src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.js"></script>
<!DOCTYPE html>
<html dir="rtl" lang="he">

<head>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/3.0.3/cookieconsent.min.css" />
</head>

</html>
peterh
  • 11,875
  • 18
  • 85
  • 108
BlackB1RD
  • 1
  • 5

4 Answers4

3

Why don't you try something like below with simple hover css.

.myButton {
  width: 200px;
  height: 50px;
  color: #fff;
  border: none;
  background-color: blue;
  transition: all 0.4s ease;
}

.myButton:hover {
  background-color: red;
}
<input type="button" value="hover me" class="myButton">
RaJesh RiJo
  • 4,302
  • 4
  • 25
  • 46
2

it looks like you're using external css files that use a override every style that you're using. Look at this JSFiddle, it will do the trick for you :)

I just copy your code and found what element is generated by the JS. Then I apply some style on it.

a.cc-dismiss{
  transition:all .25s;
}
a.cc-dismiss:hover{
  color:#ffffff;
  background-color:#63A244;
  transition:all 0.5s;
}

https://jsfiddle.net/cpg0uL31/

Lucas.S
  • 126
  • 2
  • More informations if you're not getting it : a.cc-dismiss = an "a" tag in html with the "cc-dismiss" class on it. – Lucas.S Aug 29 '17 at 12:47
  • I hope you get why you were not able to apply previous answer :) Don't hesitate to share JSFiddle link with your code, it will help us next time to give you information faster ! Have a great day – Lucas.S Aug 29 '17 at 13:03
0

The CSS :hover selector should do it.

button:hover {
   background-color: #63A244;
   color: white;
}

More info: w3schools

Vilapri
  • 71
  • 5
0

function mouseOver() {
  $("#btn").addClass("text bg");
  $("#btn").text("your text");
}

function mouseOut() {
  $("#btn").removeClass('text bg')
  $("#btn").text("Mouse over me");
}
.text {
  font-size: 30px;
  color: #FFFFF;
}

.bg {
  background-color: #63A244;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button id="btn" onmouseover="mouseOver()" onmouseout="mouseOut()">Mouse over me</button>