Jquery and js hide and display div, jqueryjsdiv

Source: Internet
Author: User

Jquery and js hide and display div, jqueryjsdiv

JQuery display and hide div:

Display:

$ ("# Id"). show ()

Hide:
$ ("# Id"). hide ()

Js display and hide div:

The visibility of div can control the display and hiding of div, but the page is blank after hiding

Style = "visibility: none ;"

Document. getElementById ("typediv1"). style. visibility = "hidden"; // hide

Document. getElementById ("typediv1"). style. visibility = "visible"; // display


By setting the display attribute, you can hide the div and release the occupied page space, as shown below:

Style = "display: none ;"

Document. getElementById ("typediv1"). style. display = "none"; // hide

Document. getElementById ("typediv1"). style. display = ""; // display



Jquery or js hides the content in a DIV. You can hide the content without displaying the content. No CSS is required. CSS will be used. I only need jquery or js to hide the content.

Jquery Syntax: <script type = "text/javascript">
$ (& Quot; #123 & quot;). hide ();
</Script>
& Lt; div id = "123" & gt; rewerwerwerh4 & lt;/div & gt;
This sentence

Use js or jq to set div display and hide

Very simple ~ Just make a judgment ~ The Code is as follows:
<Script type = "text/javascript" src = "jquery-1.8.3.min.js"> </script> <script type = "text/javascript"> $ (function () {var pm_width = $ (document. body ). width (); var width = $ ("# zheli "). width (); if (pm_width> width) {$ ("# xianshi" ).css ("display", "block ");}}); </script>
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.