0
I am trying to make an effect that by hovering the mouse over an element, if it is not selected; display the effect, in my case a text color change. Unfortunately, I’m having some difficulty. I left my code below to take a look, it is executable, so you can see how that is the result.
// Variáveis indicadoras
var tabselect = 'main'
// Variáveis de fora (css, html...)
settingsbtn = document.getElementById('settingsbtn')
mainbtn = document.getElementById('mainbtn')
telaprincipal = document.getElementById('showarea')
decoraçãocima = document.getElementById('showareatop')
// #settingsbtn:hover{
// color: #00d2ff;
// transition: all .3s;
//}
// Manipulação
settingsbtn.addEventListener('click', ()=>{
tabselect = 'settings'; // Mudando seleção de abas para settings
// Muda a ordem de cores de fundo dos botões
settingsbtn.style.backgroundColor = '#2b2b2b'
mainbtn.style.backgroundColor = '#424242'
})
mainbtn.addEventListener('click', ()=>{
tabselect = 'main';
// Muda a ordem de cores de fundo dos botões
settingsbtn.style.backgroundColor = '#424242'
mainbtn.style.backgroundColor = '#2b2b2b'
})
if(tabselect === 'main'){
// Aplicando efeito hover
$('#mainbtn').mouseover(function(){
$('#mainbtn').css({
'color': 'white',
'transition': 'all .3s'
})
});
$('#settingsbtn').mouseover(function(){
$('#settingsbtn').css({
'color': '#00d2ff',
'transition': 'all .3s'
})
});
$('#settingsbtn').mouseleave(function(){
$('#settingsbtn').css({
'color': '',
'transition': 'all .3s'
})
});
}else{
$('#settingsbtn').mouseover(function(){
$('#settingsbtn').css({
'color': 'white',
'transition': 'all .3s'
})
});
$('#mainbtn').mouseover(function(){
$('#mainbtn').css({
'color': '#00d2ff',
'transition': 'all .3s'
})
});
$('#mainbtn').mouseleave(function(){
$('#mainbtn').css({
'color': '',
'transition': 'all .3s'
})
});
}
*{
box-sizing: border-box;
overflow-y: hidden;
}
html, body{
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
#mainbtn{
width: 70px;
height: 22px;
border: none;
font-weight: bold;
font-family: poppins,sans-serif;
background-color: #2b2b2b;
color: white;
text-transform: uppercase;
z-index: 1001;
}
#settingsbtn{
width: 75px;
height: 22px;
border: none;
font-weight: bold;
font-family: poppins,sans-serif;
background-color: #424242;
color: white;
text-transform: uppercase;
z-index: 1001;
}
#showarea{
width: 100%;
height: 100%;
margin-top: 0px;
z-index: 1000;
background-color: #2b2b2b;
}
#showareatop{
width: 100%;
height: 22px;
margin-top: 0px;
z-index: 999;
background-color: #242424;
}
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="./src/style.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<title>ManwhaPing</title>
</head>
<body>
<div id="showareatop">
<button id="mainbtn">Main</button>
<button id="settingsbtn">Settings</button>
</div>
<div id="showarea"></div>
<script src="./src/script.js"></script>
</body>
</html>