2

我正在尝试在下面的代码中复制其他用户正在执行的操作:

Jquery 显示和隐藏不起作用?缺少某些东西,我无法弄清楚

但就像她一样,我也被卡住了,因为它在 Dreamweaver 中不起作用。我想我没有通过添加正确的包装正确地做到这一点。知道的人可以指出或编辑我的脚本吗?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>



<script type="text/javascript">
jQuery(document).ready(function($) 
{
    $(".social").hover(function() 
    {
        $("h1", this).hide();
        $(".networks", this).fadeIn();
    }, 
    function() 
    {
        $(".networks", this).hide();
        $("h1", this).fadeIn();
    });
});
</script>

<style>
.networks 
{
    display:none;
}
</style>
</head>

<body>
<div class="social">
    <h1>Share this</h1>
    <div class="networks">
        <p>Twitter</p>
        <p>Facebook</p>
    </div>
</div>      

</body>
</html>
4

2 回答 2

0

您可以参考正确的地址:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
于 2013-03-04T01:54:58.567 回答
0

确保您使用网络服务器(wamp 或 xampp)进行测试。如果您想在没有网络服务器的情况下对其进行测试,请下载 jquery 库并将其包含在本地

正确的包装是:

$(document).ready(function() {
    $(".social").hover(function() {
        $("h1", this).hide();
        $(".networks", this).fadeIn();
    }, function() {
        $(".networks", this).hide();
        $("h1", this).fadeIn();
    });
})

或者

$(function() {
    $(".social").hover(function() {
        $("h1", this).hide();
        $(".networks", this).fadeIn();
    }, function() {
        $(".networks", this).hide();
        $("h1", this).fadeIn();
    });
})
于 2013-03-04T01:59:22.807 回答