Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery选择“外部类”;这";_Jquery_Class_Select_Jquery Animate - Fatal编程技术网

jQuery选择“外部类”;这";

jQuery选择“外部类”;这";,jquery,class,select,jquery-animate,Jquery,Class,Select,Jquery Animate,好的,这是我的安排 HTML: 这是可行的,但由于我将使用相同的代码和类处理多个元素,所以它会影响所有元素,而不是每个元素 我不熟悉js和jquery,因此我建议您将悬停限制为当前块,首先使用最接近()找到父锚定标记,然后使用class视频图像移动到anhor的兄弟 jQuery(".video-play-button").hover( function () { jQuery(this).closest('a').next(".video-image").stop().

好的,这是我的安排

HTML:

这是可行的,但由于我将使用相同的代码和类处理多个元素,所以它会影响所有元素,而不是每个元素


我不熟悉js和jquery,因此我建议您将
悬停限制为当前块,首先使用最接近()找到父
锚定标记,然后使用class
视频图像移动到anhor的兄弟

jQuery(".video-play-button").hover(
    function () {
        jQuery(this).closest('a').next(".video-image").stop().animate({opacity: '0.7'}, 300);},
    function () {
        jQuery(this).closest('a').next(".video-image").stop().animate({opacity: '1'}, 400);
});
除了答案,这也应该有效:

jQuery(".video-play-button").parent().hover(
    function () {
        jQuery(this).next().stop().animate({opacity: '0.7'}, 300);},
    function () {
        jQuery(this).next().stop().animate({opacity: '1'}, 400);
});

你能在jsFiddle.net上做一个演示吗?不用担心,我发现了一个简单的打字错误,修复后解决了这个问题,谢谢!
jQuery(".video-play-button").hover(
    function () {
        jQuery(this).closest('a').next(".video-image").stop().animate({opacity: '0.7'}, 300);},
    function () {
        jQuery(this).closest('a').next(".video-image").stop().animate({opacity: '1'}, 400);
});
jQuery(".video-play-button").parent().hover(
    function () {
        jQuery(this).next().stop().animate({opacity: '0.7'}, 300);},
    function () {
        jQuery(this).next().stop().animate({opacity: '1'}, 400);
});