悬停并显示代码

时间:2014-09-22 23:44:23

标签: javascript jquery html

我们是ASM程序员,没有html / css / js网络体验。我希望有一系列的线,也许是30,当一个人盘旋在一条线上时隐藏的文字出现并在悬停移开时隐藏。我们从网站上的jQuery答案中获取代码,但无法使其工作。谢谢。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
    <script src="jquery-1.11.1.js"></script>
    <meta charset="utf-8"><title>puff1</title>

    </head>
    <body>
        <a href="#Dud" class="mark">Hover here</a>
        <div class="icontent">
            <p> Some nice Queen's english here ..." </p>
        </div>

$(".mark").on({
    mouseover: function() {
    $(".icontent").stop().show(1000);
    },
    mouseout: function() {
        $(".icontent").stop().hide(1000);
        }
    })
</body>
</html>

2 个答案:

答案 0 :(得分:2)

将您的代码包裹在<script>代码中:

<script>
    $(".mark").on({
        mouseover: function() {
            $(".icontent").stop().show(1000);
        },
        mouseout: function() {
            $(".icontent").stop().hide(1000);
        }
   })
</script>

答案 1 :(得分:0)

可能你需要像this这样的东西:

<script>
    $(function(){
        $(".mark").on({
            mouseenter: function() {
                $(this).next(".icontent").stop().show(1000)
            },
            mouseleave: function() {
                $(this).next(".icontent").stop().hide(1000);
            }
        });
    });
</script>

因为你说:

  

我希望有一系列的线,也许是30,   当一个人在一条线上盘旋时隐藏的文字出现并隐藏在何时   悬停移开了。

因此,使用$(".icontent")显示或隐藏将导致所有具有类icontent的元素同时显示/隐藏。

相关问题