Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.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_Wordpress_Hover_Addclass_Removeclass - Fatal编程技术网

Jquery 自定义颜色悬停在循环中的每个帖子上

Jquery 自定义颜色悬停在循环中的每个帖子上,jquery,wordpress,hover,addclass,removeclass,Jquery,Wordpress,Hover,Addclass,Removeclass,找不到以下场景的逻辑: 在一个循环中有六个帖子,每个帖子都有一个带有自定义字段的颜色值。 当鼠标悬停在一篇文章的摘录上时,它应该将摘录的背景更改为自定义字段设置的颜色 它正在工作,但将鼠标悬停在一个帖子上会显示每个帖子的隐藏颜色,而不仅仅是一个帖子 有没有办法将post ID存储在变量中,然后将这些变量传递给JQuery addClass/removeClass函数 多谢各位 HTML: }) 显然,由于3some类的存在,上述代码将无法工作。有没有办法在JQuery中获取$display变量,

找不到以下场景的逻辑:

在一个循环中有六个帖子,每个帖子都有一个带有自定义字段的颜色值。 当鼠标悬停在一篇文章的摘录上时,它应该将摘录的背景更改为自定义字段设置的颜色

它正在工作,但将鼠标悬停在一个帖子上会显示每个帖子的隐藏颜色,而不仅仅是一个帖子

有没有办法将post ID存储在变量中,然后将这些变量传递给JQuery addClass/removeClass函数

多谢各位

HTML:

})

显然,由于3some类的存在,上述代码将无法工作。有没有办法在JQuery中获取$display变量,然后对其应用一些css?

好的,我想出来了: 从具有图像和具有绝对位置的不可见div的循环div:

<div class="wrap">
<div id="<?php echo $display ?>" class="indextitle_seethrou">
</div>
<div class="pic">
    <?php
    if ( has_post_thumbnail() ) {
        the_post_thumbnail('featured_thumb');
    } else {
    } ?>
</div>
</div><!--wrap ends -->
页面上有许多帖子,每个帖子的唯一颜色值存储在$display变量中。 我想把这些独特的颜色显示为一个覆盖在悬停图像上的不透明度。 在我的第一个方法中,我使用一个类作为选择器,但将鼠标悬停在一个图像上会显示所有的覆盖。 我没有使用类作为选择器,而是将整个内容包装在一个div中,并使用JQuery将该div中的第一个元素作为目标。在我的例子中,包装中的第一个元素是div,它具有我想要在悬停在图像上时显示的唯一背景色

请注意,.wrap、.pic和.indextitle_seethrou类在我的CSS中有绝对位置,.indextitle_seethrou类也有display:none CSS属性


谢谢。

一些代码会有所帮助。请发布一些示例代码。
$('.threesome').hover(function() {
$('.indextitle_seethrou').stop(true, true).fadeIn('fast');
            }, function() {
$('.indextitle_seethrou').stop(true, true).fadeOut('fast');
<div class="wrap">
<div id="<?php echo $display ?>" class="indextitle_seethrou">
</div>
<div class="pic">
    <?php
    if ( has_post_thumbnail() ) {
        the_post_thumbnail('featured_thumb');
    } else {
    } ?>
</div>
</div><!--wrap ends -->
$(document).ready(function()
{
 $(".wrap").mouseover(function ()
{  
 $(this).children('div:first').stop(true, true).fadeIn('fast');
});
 $(".wrap").mouseout(function ()
{ 
 $(this).children('div:first').stop(true, true).fadeOut('fast');
});
});