【发布时间】:2019-10-06 16:54:23
【问题描述】:
我使用 bxslider4 并且启用了字幕。我想添加标题链接。我做了一些,但它只适用于第一个。如何将所有链接附加到每个标题。我已经编辑了 bxslider javascript 文件。
我的滑块 php 代码:
foreach ($manset_images as $man_img => $value2) {
?>
<div>
<a id="slayt_resim_link" href="index.php?url=content&id=<?=$value2->content_id; ?>">
<img src="<?php echo URL; ?>public/upload/<?=$value2->content_foto?>" title="<?=$value2->content_title?>" data-url="index.php?url=content&id=<?=$value2->content_id; ?>" style="width:100%; height: 350px;">
</a>
</div>
<?php
}
?>
我在原始 bxslider javascript 文件中添加了以下代码以获取图像链接并更改标题 href:
// find image link
var captionLink = $this(this)$(slayt_resim_link).attr('href');
$('#manset_caption_link').attr('href', captionLink);
此代码提供了第一个标题的应用。如果我将 captionLink 添加到 href="" 我想我可以解决问题
<a id="manset_caption_link" href=""> 但我不知道该怎么办。
javascript 代码的最后状态:
// bxslider javascript file 719. line
/**
* Appends image captions to the DOM
*/
var appendCaptions = function() {
// cycle through each child
slider.children.each(function(index) {
// get the image title attribute
var title = $(this).find('img:first').attr('title');
//------------------ added after ----------------------------
// find image link
var captionLink = $this(this)$(slayt_resim_link).attr('href');
$('#manset_caption_link').attr('href', captionLink);
//------------------------------------------------------------
// append the caption
if (title !== undefined && ('' + title).length) {
$(this).append('<div class="bx-caption"><a id="manset_caption_link" href="---Add captionLink---!!!!!"><span>' + title + '</span></a></div>');
}
});
};
【问题讨论】:
标签: javascript php jquery html bxslider