匹配递增的类与来自不同循环的递增的id
经过几个小时的研究和尝试和错误,我在这里开始我的第一个问题。 如果可以用wordpress语法更好地完成。 否则我认为我接近解决方案。
我想在wordpress模板页面上使用自定义图库,但是使用来自某些类别的post图片及其中的内容。 到现在为止还挺好。
在我的designerin.php模板中,我给每个图像一个类img-x。
class="img-
内容得到id img-x
id="img-
计数器只是一个增量。 因此图像1具有类img-1,图像2 img-2等等。 现在,我想要在单击此特定图像时显示在wordpress编辑器中创建的该图像的相关内容。
假设您单击图像5并想要图像5中的内容。 我坚持我说的步骤(在jQuery中),显示内容
if .img-x == #img-x { display the_content() }
够了 – 这是我的jQuery代码:
$(".large-img-wrapper").hide(); $('.gallery li').on('click', function(e) { e.preventDefault(); var largeImgLink = $(this).find('a').attr('href'); $(".large-img-wrapper").first().fadeIn(); var imgContent = $('#img-5').html(); $('#large-img').remove(); $('#append-id').remove(); $(".large-img").append('').fadeIn(); $(".large-img").append('' + imgContent + '').fadeIn(); $(".large-img-container .img-title").remove(); });
var imgContent只是一个测试。 每个图像显示此刻图像5中的内容。 我的模板页面代码:
Alle Kategorien cat_name; } } $cat_name = get_category(get_query_var('cat'))->name; ?> <a href="#" class="sort-link" data-category=""> cat_name; } } ?> - **<a href="https://stackoverflow.com/questions/28528526/match-incremented-class-with-incremented-ids-from-different-loops-jquery-word/" class="thumbnail img-" data-categories=""><img src="https://stackoverflow.com/questions/28528526/match-incremented-class-with-incremented-ids-from-different-loops-jquery-word/" alt="">**
** - <div class="img-content" id="img-">
**