1

这应该是不言自明的,非常感谢任何帮助!

jQuery代码

    $("#larrow img").hide();
    $("#rarrow img").hide();

    $("#rarrow").hover(arrowIn,arrowOut);
    $("#larrow").hover(arrowIn,arrowOut);

    function arrowIn()
    {
    $(this+" img").show()
    }
    function arrowOut()
    {
    $(this+" img").hide()
    }

我也尝试过以img为背景

    $("#larrow").css('visibility','hidden');
    $("#rarrow").css('visibility','hidden');

    $("#rarrow").hover(arrowIn,arrowOut);
    $("#larrow").hover(arrowIn,arrowOut);

    function arrowIn()
    {
    $(this).css('visibility','visible')
    }
    function arrowOut()
    {
    $(this).css('visibility','hidden')
    }

显然无济于事,提前感谢您的帮助!

4

2 回答 2

2

您不能thisimg选择器连接。无论如何,这段代码可能会更短:

function arrow() {
    $("img", this).toggle();
}

$("#larrow img, #rarrow img").hide();
$("#rarrow, #larrow").hover(arrow);

演示:http: //jsfiddle.net/4fHL3/

于 2012-06-03T00:22:13.607 回答
1

由于您没有发布 Html,您可以尝试以下操作:

function arrowIn()
{
    $(this).show();
}
function arrowOut()
{
    $(this).hide();
}

或者

function arrowIn()
{
    $('img', this).show();
}
function arrowOut()
{
    $('img', this).hide();
}
于 2012-06-03T00:20:24.380 回答