1

そこで、プリロードの目的でイメージ スワップを実行する新しい方法を試すために、この小さなコードを書きましたが、少し問題が発生しています。

私の問題は、パディングとテキストを含む画像のコンテナーがあることですが、ロールオーバーのアクティブ化は、コンテナーではなく、誰かが画像をロールオーバーしたときにのみ発生します。私は少し間違っているに違いありません。誰かが私を助けてくれることを願っています。まだまだ勉強中!

html は次のとおりです。

<div class="projectThumb">
    <img src="/img/aeffect_button_static.gif" width="146" height="199" class="static" name="aeffect" alt="" />        
    <img src="/img/aeffect_button_rollover.jpg" width="146" height="199" class="rollover" name="aeffect" alt="" />
    <p class="title">A.EFFECT: Film Poster</p>
</div>

ここにjqueryがあります:

$(document).ready(function(){
    $(".rollover").hide();
$(".projectThumb").mouseenter(
        function(){
            $(this).attr(".static").hide();
        }, 
        function(){
            $(this).attr(".rollover").show();
        });
$(".projectThumb").mouseleave(
        function(){
            $(this).attr(".rollover").hide();
        },
        function(){
            $(this).attr(".static").show();
        });
});
4

2 に答える 2

4

hoverを探していると思います:

$(document).ready(function(){
    $(".rollover").hide();
    $(".projectThumb").hover(
    function(){
        $(this).find(".static,.rollover").toggle();
    }, 
    function(){
        $(this).find(".static,.rollover").toggle();
    });
});

mouseenter と mouseleave はどちらも引数を 1 つしか取りませんが、2 つのコールバック関数を定義しています。

于 2009-09-08T23:02:22.803 に答える
0

試してみませんか:

$(".projectThumb").bind("mouseenter mouseleave", function(e) {
    $(this).toggle();
});
于 2009-09-22T11:44:22.407 に答える