我试图操纵一个包含一段文本的特定元素,我想把它包装在一个href中,尽管我使用css背景红色来证明元素的目标。
我正在使用Galleria 1.2.8,我目前有一个函数,在ajaxComplete和工程上火灾。
这是当前的工作函数:
// dynamically create data-links for all gallery items
$(document).ajaxComplete(function() {
$('#galleria a').each(function() {
var $href = $(this).attr('href');
$(this).children().attr('data-link',$href);
});
$('.galleria-info-description:contains("NN")').css('background', 'red');
});
最后一行是该函数不工作的部分
这是一个简化的html基本块,它是动态创建的:
<div class="galleria-container">
<div class="galleria-stage">
</div>
<div class="galleria-thumbnails-container">
</div>
<div class="galleria-info">
<div class="galleria-info-text">
<div class="galleria-info-description">
NN Contemporary Art
</div>
</div>
<div class="galleria-info-link">
</div>
<div class="galleria-info-close">
</div>
</div>
</div>
我已经尝试了相当多的变化,创建一个变量来保存内容和操作。通过深入研究这个班级的几位家长来瞄准这个班级,似乎没有任何效果。我可以,在ajaxComplete上,从页面中完全删除#galleria id,只是似乎无法获得对象中返回的特定元素。
TIA。
所以这有点笨拙,但我检查了这里的galleria文档:检索http://galleria.io/docs/api/methods/
我现在已经在galleria init之前添加了以下代码:
Galleria.ready(function(options) {
$targetElem = ( this.getData([10]));
$targetElem.description = '<a href="http://www.nncontemporaryart.org/exhibitions/guests- hosts" target="_blank">NN Contemporary Art Northampton</a>';
});