Here is the code:

var smiles = $("#smilesChoose"); $("#smilesBtn").click(function () {smiles.toggle(duration = 600); }); 
 .enter_send_mess{ float: left; width: 50px; height: 19px; margin-top: 2px; margin-left: -1px; border-top: 1px; box-shadow: 0px -2px 1px #9b9b9b; opacity: 1; } .enter_send_mess:hover{ cursor: pointer; opacity: 0.7; } #smilesChoose { display: none; position: absolute; right: 100px; top: 50px; background: #fff; padding: 10px; width: 200px; border: 1px solid #eee; -moz-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); -webkit-box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); box-shadow: 0 0 10px rgba(0, 0, 0, 0.5); } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <div class="wrap_send_mess"> <div class="enter_send_mess" id="smilesBtn">Нажми</div> <div id="smilesChoose">o:) oO 3:) <3 :* :-) 8| :/ ;) :'( >:( :( 8) :p :D</div> </div> 

I do not understand why everything works here, but I don’t. When you click on a button, a hidden block appears and on the second click it disappears. Only here on my page it only appears, but does not want to disappear. What could be the problem?

  • It is likely that the problem is in the surrounding code (html and all). Is the button itself still active after the first trigger? Does the mouse react? - Kirill Korushkin
  • yes, cursor: pointer; and opacity: 0.7; it works fine - Vitaliy Fesyura
  • what is most interesting, if you add alert ("ddd"); then the dialog will appear with each press, but the necessary block does not want to disappear. - Vitaliy Fesyura
  • and put the script after the code;) - Kirill Korushkin
  • one
    Have you ever read about the parameters of the toggle method? it can work either without parameters, or accept a boolean value (show / hide), and you write with some kind of fright in the parameter duration = 600 . this expression, it will be executed, the duration variable will become equal to 600, the result of the expression will be a logical true . therefore, your blocks will always be shown. - teran

0