0
People need to make sure that when you mouse(Hover) in a div
she changes the contents of the side
the image explains well how the process should be done when hovering over the div
should exchange the texts on the side would like to know if it is possible to do this with hover
follows my code:
<div class="col-md-4">
<div class="row">
<div class="needs">
<h4 class="title">Quais são suas necessidades?</h4>
<div class="col-md-6 no-padding">
<div onmouseover="change(1)" class="service -bg" id="p1">
<i class="icon -thecnology"></i>
<p class="description migration">Migração</p>
</div>
</div>
<div class="col-md-6 no-padding">
<div onmouseover="change(2)" class="service -bg" id="p2">
<i class="icon -project"></i>
<p class="description project" style="white-space: nowrap">Projeto Personalizado</p>
</div>
</div>
<div class="col-md-6 no-padding">
<div onmouseover="change(3)" class="service -bg" id="p3">
<i class="icon -security"></i>
<p class="description security">Segurança</p>
</div>
</div>
<div class="col-md-6 no-padding">
<div onmouseover="change(4)" class="service -bg" id="p4">
<i class="icon -optimization"></i>
<p class="description optimization">Otimização</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-4">
<div class="box-descriptions" id="content">
<p id="content-one" class="content one">Podemos ajudar a migrar seus aplicativos para a Origiweb, tornando essa
transiçao mais fácil e suave para a sua equipe.</p>
<p id="content-two" class="content two">Podemos ajudar a migrar seus aplicativos para a Origiweb, tornando essa
transiçao mais fácil e suave para a sua equipe.</p>
<p id="content-tree" class="content tree">Podemos ajudar a migrar seus aplicativos para a Origiweb, tornando essa
transiçao mais fácil e suave para a sua equipe.</p>
<p id="content-for" class="content four">Podemos ajudar a migrar seus aplicativos para a Origiweb, tornando essa
transiçao mais fácil e suave para a sua equipe.</p>
</div>
</div>
JS:
<script>
function change(val) {
var x = document.getElementsByClassName('content');
for(var i = 0; i < x.length; i++) x[i].style.display = 'none';
document.getElementById('content'+val).style.display = 'block';
}
</script>
Friend thanks for the answer only one thing that js have to be on the head or body down there ?
– Felipe Henrique
A good practice, in fact, is to use the scripts just before the closure of
</body>
, few cases that do not follow this rule.– Thiago Santos
@Kirito if it’s right for you, mark it as right, to help other people too, a hug!
– Thiago Santos
only one thing this tag <p onmouseover="change(1)" id="P1"> I’m going to exchange for that <div onmouseover="change(2)" class="service -bg" id="P2"> no problem being a right div ? or has to be a <p>
– Felipe Henrique
Can be any TAG, including
<img>
,<span>
,<a>
... Only the value 2 within the functionmudar(2)
I use to call the div conteudo2, if it were 3 I would call the 3 and so on, you understood the logic?– Thiago Santos
I will edit my question and I will paste with the changes I made based on your answer ta giving an error it shows the first text when I step the mouse over the div it disappears and no longer appears
– Felipe Henrique
It’s edited if you can take a look and see where I’m going wrong
– Felipe Henrique
@Kirito just change the content-one ID to
content1
and in Javascript switch todocument.getElementById('content'+val)
– Thiago Santos