1

I am creating a Images tabs with jquery and i am not using any css here.. I am using anchors <a>

When a user hovers on anchor ie focus on <a>, it should fire something but its not working

<div class="container">
    <div class="TabMenu">
        <span><a href="#"><img src="images/A.png"></a></span>
        <span><a href="#"><img src="images/B.png"></a></span>
        <span><a href="#"><img src="images/C.png"></a></span>
    </div>
</div>

I tried to work out with jquery but it not working out, here is code for jquery

$(".container .TabMenu span a").click(function(){
 alert("Click working");
});

Is there any code where anchors get hover, visited, active

$(".container .TabMenu span a:visited").(function(){
 alert("You have visited");
});

$(".container .TabMenu span a:hover").(function(){
 alert("Hover working");
});

$(".container .TabMenu span a:active").(function(){
 alert("Hover working");
});

Is there any special functional code for anchor..

and do not use hover function of jquery and I know that above 3 anchor code are wrong.

4

1 回答 1

0

要在悬停时执行代码,您可以使用 mouseenter() 和 mouseleave() 方法或 hover () 方法:

$(".container .TabMenu span a").mouseenter(function() {
    alert("hover start")
});

$(".container .TabMenu span a").mouseleave(function() {
    alert("hover end")
});

$(".container .TabMenu span a").hover(function() {
    alert("hover start")
}, function() {
    alert("hover end")
});
于 2011-12-02T06:45:15.727 回答