Change properties of a div with one click

Asked

Viewed 171 times

0

I have the following html:

<div id="personalizada">
    <i class="fa fa-plus" aria-hidden="true"></i>
</div>
<div class="balao"></div>

I would like when I click id="custom" the opacity of id="ballad" change to 1.

1 answer

2


Would that be?

function mudaOpacidade() {
  document.getElementsByClassName("balao")[0].style.opacity=1;
}
.balao {
  height: 120px;
  width: 120px;
  background-color: #0f0;
  opacity: 0;
}
<div id="personalizada" onclick="mudaOpacidade()">
  Cliqyaqui
  <i class="fa fa-plus" aria-hidden="true"></i>
</div>
<div class="balao"></div>

With jquery it would be:

$("#personalizada").on("click",function(){
$(".balao").css("opacity",1);
});
.balao {
  height: 120px;
  width: 120px;
  background-color: #0f0;
  opacity: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="personalizada">
  Clique aqui
  <i class="fa fa-plus" aria-hidden="true"></i>
</div>
<div class="balao"></div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.