<button class ="btn btn-default pull-right" id="save" onclick="echoq();">Сохранить</button> <div id="resultVK" class="alert alert-success alert-dismissable col-md-6 pull-right" style="display:none;"> <button class="close" id="close" onclick="close();">×</button> Текст </div> 

Functions:

 function echoq(){ $( "#resultVK" ).removeAttr( "style" ); } function close(){ $( "#resultVK" ).attr("style","display:none"); } 

Those. when you click save, show the block. When you press x - hide. But for some reason, hiding does not work.

    3 answers 3

    Why does not it work? The close function does not work, since js has a native close method and when it is called, it is not your function that is called, but the native one.

    Better solution

     $(document).on('click', '#save', function() { $('#resultVK').show(); }); $(document).on('click', '#close', function() { $('#resultVK').hide(); }); 
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button class ="btn btn-default pull-right" id="save">Сохранить</button> <div id="resultVK" class="alert alert-success alert-dismissable col-md-6 pull-right" style="display:none;"> <button class="close" id="close">×</button> Текст </div> 

      why delete style? change only the display:

       $( "#resultVK" ).css("display","none");// hidden $( "#resultVK" ).css("display","");// show 

        The window has a close function. It is impossible to redefine it. Therefore it is worth changing the name of the function. For example, on closeResult .

        Using inline-JS ( onclick="" ) has not been welcomed by society for many years. The problem with the name of the function - another stone in the garden inline_JS.
        And, of course, to work with styles it is better to use .css() .