开发者

jQuery - Hiding text

I have the following code and trying to hide XYZ. Why isn't it getting hidden using this code?

<html>
<head>
<script type="text/javascript">
        $(function(){
               开发者_运维知识库$('#hide').hide();
    });
</script>
</head>
<body>
<div id="hide">
XYZ
</div>
</body>
</html>

Thanks.


You need to include a reference to jQuery in order to use jQuery functions

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript">
    $(function(){
      $('#hide').hide();
    });


You are using jQuery syntax, but you didn't add jQuery itself, that's why.

Add this to the head tag, before your current script block:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>


You need to include jQuery.js in your source file.


You are not loading jQuery.

try to load it from Google:

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js'></script>

before your script.


You have forgot to include jQuery library

<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.js'></script>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜