-1

カーソルを合わせるとリンク付きの div を表示するアイコンがあります。ユーザーはこのリンクをクリックできるはずですが、マウスがアイコンから離れると消えます。これを防ぐ方法を知っている人はいますか?

コード:

$('.div1').hover(function(e){   
    e.preventDefault();
    e.stopPropagation();
    $(this).next().show('fast');
},
function(e){
    e.preventDefault();
    e.stopPropagation();    
    $(this).next().hide('fast');
});

問題を示すために JSfiddle を作成しました。

http://jsfiddle.net/2wrjG/5

4

3 に答える 3

0

画像にカーソルを合わせると、div が表示されます。リンクをクリックしたときにのみリンクを非表示にしたい場合は、これが役立つと思います。

enter code here

 $('.domaininfo').hover(function (e) {
          e.preventDefault();
          e.stopPropagation();
          $(this).next().show('fast');
    },function (e) {
            e.preventDefault();
            e.stopPropagation();
            $('.domain-info-window').click(function (e) {
                $(this).hide();
            });
        });
于 2013-03-26T14:33:55.413 に答える
0
$('.domaininfo').hover(function (e) {
    e.preventDefault();
    e.stopPropagation();
    $(this).next().show('fast');
},
function (e) {
    e.preventDefault();
    e.stopPropagation();
    $('.domain-info-window').hover(function (e) {
        e.preventDefault();
        e.stopPropagation();
    },
    function (e) {
        e.preventDefault();
        e.stopPropagation();
        $(this).hide('fast');
    });
});

デモはこちら

于 2013-03-26T14:20:29.143 に答える
0

問題は、リンクをクリックしようとしたときに img-tag を残すことです。すべてをラップして、このラップでホバーを呼び出すことをお勧めします。

ここで動作するフィドル: http://jsfiddle.net/2wrjG/2/

$('.wrapper').hover(function (e) {
    e.preventDefault();
    e.stopPropagation();
    $(this).children('a').show('fast');
},

function (e) {
    e.preventDefault();
    e.stopPropagation();
    $(this).children('a').hide('fast');
});

HTML 部分:

<div class="wrapper">
<img class="domaininfo" src="http://domeinwinkel.sitestatus.nl/gfx/itje.png">
<a class="domain-info-window" id="domain-info-window-2" href="#">
Is deze domeinnaam bij een andere provider geregistreerd maar wil je profiteren van de voordelen van Domeinwinkel? Verhuizen naar Domeinwinkel is snel geregeld!
</a>
</div>

CSS:

.domaininfo {
    position: relative;
    top: 0px;
    left: 0px;
}
于 2013-03-26T14:21:49.197 に答える