开发者

Set Javascript display to "none" [duplicate]

This question already has an answer here: Closed 11 years ago.

Possible Duplicate:

force Javascript to not execute till display =“inline”

I've got a div like the following...

    <div id="tag" style="width: 360px; display:none">
    <script type="text/javascript">
              Crazy Wizardry Javascript here!
            </script>
    </div>

The Javascript inside is displaying.. is there a way that I can force it to not display on till I set the div to displa开发者_Go百科y "inline"?


It doesn't display at all: http://jsfiddle.net/XYUpJ/

But this is because that script tag does not output anything into that container. script tags themselves are display:none so you should never ever see their content.

If instead you mean you want the script to only run when the down that owns it becomes visible, then no you can't do that in this way. Visibile or not, a script tag just runs.

Instead you want to define a function in a script tag, and call that function when you set the #tag to be visible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜