开发者

jQuery - Hiding text

开发者 https://www.devze.com 2023-04-11 06:02 出处:网络
I have the following code and trying to hide XYZ. Why isn\'t it getting hidden using this code? <html>

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

精彩评论

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