高级自定义字段-wordpress +转发器

时间:2017-12-05 14:36:53

标签: wordpress slider repeater advanced-custom-fields

我将滑块与转发器字段组合在一起。 在转发器下我有2个子场。一个称为“图像”,另一个称为“标题”

此滑块有一个名为“selected-item”的类,在选择图像时会动态显示该类。 (当这个类在图像上时,图像会改变它的大小。)

如何定义当“选定项目”类在某个图像上时,还会出现图像同一行的“标题”?

这是显示图像的代码:

t1.primary t2.primary t2.secondary t2.timestamp
         1          2            1           5  --Leftjoined the newest entry in range
         2          5            2           5 
         3       NULL         NULL        NULL

>

1 个答案:

答案 0 :(得分:1)

将标题隐藏在开头,然后在应用选定项目类时显示标题。如果h1将始终位于图片代码旁边,请使用+选择器。

h1 { display: none; }
.selected-item + h1 { display: block; }

或者您可以使用jquery检测类更改事件。



function checkForChanges()
{
    if ($('img').hasClass('selected-item'))
        $('h1').css('display','block');
    else
        setTimeout(checkForChanges, 500);
}

checkForChanges();

$("#click").on('click', function(){
    $('img').addClass("selected-item");
});

    h1 { display: none; } /* Keep the title hidden in the beginning */
     /* Show the title when selected-item class is applied */

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<img src="http://via.placeholder.com/100x100" width="100" height="100">
<h1>title</h1>
<div id="click">click me</div>
&#13;
&#13;
&#13;

相关问题