onclick calling hide-div function not working

前端 未结 3 1370
刺人心
刺人心 2020-12-04 03:05

I\'ve been fighting with this simple piece of code forever. I\'m trying to use a

3条回答
  • 2020-12-04 03:50

    Let's do something in jQuery:

    <button type="button" id="btn">OK</button>
    <div id="myDiv">Div's contents here</div>
    

    Now, you need just use the code below to do what you want:

    <script type="javascript">
    $(document).ready(function(e) {    
       $("#btn").click(function () {
          $("#myDiv").hide();
       });
    });
    </script>
    

    Notice: you can have some properties for hide() function: Fast and slow. This will affect on the speed of hiding action.

    $("#myDiv").hide("slow");
    

    I hope this can help you.

    0 讨论(0)
  • 2020-12-04 03:55

    Try changing the close function name to something else like closeit because it may be confusing it with the window.close() function.

    0 讨论(0)
  • 2020-12-04 04:01

    Try document.getElementById('wrong').setAttribute('style', 'display:none');

    0 讨论(0)
提交回复
热议问题