Jquery and js implementation of div hide and display methods

  • 2020-03-30 04:01:13
  • OfStack

JQuery to div display and hide:

Display:


$("#id").show()

Hidden:
The same code at the page code block index 0

Js to div display and hide:

Div's visibility controls the display and hiding of divs, but the page shows whitespace after hiding


style="visibility: none;"

document.getElementById("typediv1").style.visibility="hidden";//Hidden < br / >
document.getElementById("typediv1").style.visibility="visible";//According to < br / >

By setting the display property, you can make div hide and free up the occupied page space, as shown below


style="display: none;"

document.getElementById("typediv1").style.display="none";//Hidden < br / >
document.getElementById("typediv1").style.display="";//According to < br / >


Related articles: