The +
just get the brothers in front of that element and not the previous ones. To do what you want easily, use jQuery like this:
<style>
.muda-fundo{
background-color: #000099 !important;
}
</style>
First to work jQuery just paste this link before the call of the jQuery function on your page, usually puts itself in the header
, but whatever, it just can’t be after the call:
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
Here I gave you the jQuery CND link, so you don’t have to download it, but if you run out of internet, it won’t work. So I recommend that you download this code into a folder in your project, usually the default is js then it gets like this:
<script src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#botao').hover(function(){
$('#fundo').toggleClass('muda-fundo');
});
});
</script>
Background of which element should change color when having Hover on the button? That wasn’t clear.
– Woss
There are two elements, the background and the button. By hovering the mouse over the button, I want the background (could be a div) to change to the color I specify.
– André Ciappina
With the elements being siblings you can even do it with just CSS, but with the button inside the div, No. What would that be div?
– Woss