Can I control these animations with JS/JQuery instead of CSS hover action?
.button {
width: 350px;
height: 300px;
margin: 100px auto;
position: relative;
border: solid 2px #cbd4d9;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.button:hover .hoverBtn:before, .button:hover .hoverBtn:after {
opacity: 1;
-webkit-animation: open 0.8s;
animation: open 0.8s;
animation-fill-mode: forwards;
animation-timing-function: cubic-bezier(0.39, 0.575, 0.565, 1);
animation-direction: normal;
}
.button:hover .hoverBtn-bottom:before, .button:hover .hoverBtn-bottom:after {
opacity: 1;
-webkit-animation: openB 0.8s;
animation: openB 0.8s;
animation-delay: 0.8s;
animation-fill-mode: forwards;
animation-timing-function: cubic-bezier(0.39, 0.575, 0.565, 1);
animation-direction: normal;
}
.hoverBtn {
width: 100%;
height: 300px;
position: absolute;
top: -1px;
}
.hoverBtn:before {
position: absolute;
content: '';
...
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>Square border animation</title>
<link rel="stylesheet" href="css/style.css">
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<div id="target">
Click here
</div>
<div id="myButton" class="button">
<a href="#">
<div class="hoverBtn"></div>
<div class="hoverBtn-bottom"></div>
</a>
</div>
<script>
$( "#target" ).click(function() {
alert( "Handler for .click() called." );
});
</script>
</body>
</html>
All code has been included.
I want to trigger the animation using JS/jQuery instead of on hover.
I've attempted some solutions but need help with implementing class changes.
Sincerely,
Jonathan.