How .show() and .hide() work in jquery

This question already has an answer here:

  • Equivalent of jQuery .hide() to set visibility: hidden 4 answers

  • Add display none to your html element

    <input type="text" id="input1" style="display: none" />
    

    or with css

    #input1, #input2 {
      display: none;
    }
    

    You can set their initial style display to none . It is better to avoid inline styles.

    CSS

    #input3, #input4 {
      display: none;
    }
    

    In your case, your jQuery is handling this. Before it gets executed, your HTML gets parsed & hence you are able to see the inputs until your JavaScript gets executed.

    Hope it helps!


    create a css like this.

    .hide
    {
    display : none
    }
    

    and use the hide class for the div you want to hide initially.

    链接地址: http://www.djcxy.com/p/83556.html

    上一篇: 隐藏CSS元素而不更改显示属性

    下一篇: .show()和.hide()如何在jquery中工作