0

如何使此脚本从仅悬停到 onclick 和悬停:

$j = jQuery.noConflict();
$j(document).ready(function () {
    $j(".swatch-anchor").hover(function () {
        var newTitle = $j(this).attr("title");
        $j("#colour-name").html(newTitle);
    },
    function () {
        var swapTitle = $j("#colour-name").html();
        $j(this).attr("title", swapTitle);
        $j("#colour-name").html("");
    });
});
4

2 回答 2

1

尝试这个:

$j = jQuery.noConflict();
$j(document).ready(function () {
    $j(".swatch-anchor").on('click mouseenter',function () {
        var newTitle = $j(this).attr("title");
        $j("#colour-name").html(newTitle);
    });

    $j(".swatch-anchor").on('mouseleave',function () {
        var swapTitle = $j("select-option.selected a").text();
        $j("#colour-name").html("");
    });
});
于 2013-09-11T20:35:51.347 回答
0

解决了:

http://jsfiddle.net/4cPQG/

$j(".swatch-anchor")
.on('mousedown mouseover', function () {
    //...
})
.on('mouseup mouseout', function () {
    //...
});
于 2013-09-11T20:14:39.173 回答