How to keep an element hidden even before document.ready?

Water Cooler v2

This must have an answer already but I can't find it.

My div, which I want hidden on page load shows up for a fraction of a second until I explicitly hide it in the document.ready function.

$(document).ready(() => $("#myDiv").hide());

Short of not having it and re-creating it ($.append / $.add ) or making it the same background color as its background to hide it, how do I ensure that it remains hidden on page load?

Kristian Salo

You could toggle CSS properties on the div. display: none; prevents the element from being rendered at all, and visibility: hidden; will render it (occupy space for it from the layout), but makes it invisible. When you want to display the element, just remove the property you set.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

angle.element(document).ready の代替

分類Dev

How can I use a for-loop within a $(document).ready(function(){})?

分類Dev

$(document).ready shorthand

分類Dev

Typescript 3.0 with $(document).ready

分類Dev

Typescript 3.0 with $(document).ready

分類Dev

Jquery Mobile $(document).ready();

分類Dev

ジャスミンテストangular.element(document).ready

分類Dev

How can I hide parent element if child element is hidden?

分類Dev

$(document).ready(function()VS $(function(){

分類Dev

Statement in $(document).ready( function() not functioning

分類Dev

How to keep an IntentService running even when app is closed?

分類Dev

how to keep running the loop in python even after a KeyError

分類Dev

How to keep items in cart even after refresh using vuex

分類Dev

How to apply jQuery to .element:before:hover?

分類Dev

How to filter an html ajax response's elements before inserting into document?

分類Dev

jQuery-複数の$(document).ready ...?

分類Dev

window.onload対$(document).ready()

分類Dev

jQuery document.readyとPhonegap deviceready

分類Dev

jQuery $(document).readyおよびUpdatePanels?

分類Dev

$(document).readyでjQueryなし

分類Dev

$(document).readyは必要ですか?

分類Dev

Why is $(document).ready needed after the <script> tag?

分類Dev

Is there a way to determine if a function is running in document ready or not?

分類Dev

Javascript function inside document.ready

分類Dev

(document).ready内の関数

分類Dev

PHPと$(document).ready()の競合

分類Dev

Show modal dialog when document.ready

分類Dev

Jquery document.ready not triggered without alert

分類Dev

Wait for providers constructor to be ready before using it

Related 関連記事

  1. 1

    angle.element(document).ready の代替

  2. 2

    How can I use a for-loop within a $(document).ready(function(){})?

  3. 3

    $(document).ready shorthand

  4. 4

    Typescript 3.0 with $(document).ready

  5. 5

    Typescript 3.0 with $(document).ready

  6. 6

    Jquery Mobile $(document).ready();

  7. 7

    ジャスミンテストangular.element(document).ready

  8. 8

    How can I hide parent element if child element is hidden?

  9. 9

    $(document).ready(function()VS $(function(){

  10. 10

    Statement in $(document).ready( function() not functioning

  11. 11

    How to keep an IntentService running even when app is closed?

  12. 12

    how to keep running the loop in python even after a KeyError

  13. 13

    How to keep items in cart even after refresh using vuex

  14. 14

    How to apply jQuery to .element:before:hover?

  15. 15

    How to filter an html ajax response's elements before inserting into document?

  16. 16

    jQuery-複数の$(document).ready ...?

  17. 17

    window.onload対$(document).ready()

  18. 18

    jQuery document.readyとPhonegap deviceready

  19. 19

    jQuery $(document).readyおよびUpdatePanels?

  20. 20

    $(document).readyでjQueryなし

  21. 21

    $(document).readyは必要ですか?

  22. 22

    Why is $(document).ready needed after the <script> tag?

  23. 23

    Is there a way to determine if a function is running in document ready or not?

  24. 24

    Javascript function inside document.ready

  25. 25

    (document).ready内の関数

  26. 26

    PHPと$(document).ready()の競合

  27. 27

    Show modal dialog when document.ready

  28. 28

    Jquery document.ready not triggered without alert

  29. 29

    Wait for providers constructor to be ready before using it

ホットタグ

アーカイブ