How can i change css with javascript when i click on it? I would like to change .javakast to .javakast2 and when i click multiple times on it should move back and forth.
<script>
$(".ribad").click(function(){
$("javakast").toggleClass("javakast2");
});
</script>
CSS
.javakast{
background-color:blue;
width:200px;
height:200px;
margin-top:-20px;
margin-left:-20px;
position:absolute;
z-index:999999;
}
.javakast2{
background-color:red;
width:200px;
height:200px;
margin-top:-20px;
margin-left:300px;
position:absolute;
z-index:999999;
}
HTML
<div class="ribad">
<div class="javakast"></div>
<div>
Use your jquery method inside
<script>
$(function(){
$(".ribad").click(function(){
$(".javakast").toggleClass("javakast2");
});
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With