如何替换“echo ucwords($row2[mainImage1]);” 在下面标签的 href 属性中使用“echo $row2[selectionThumb3];” 从下面使用 Javascript 的标签的 src 属性?
这是我的代码的外观:
<img class="thumbNotSelected" src="../images/ThumbSelection/<?php echo $row2[selectionThumb3]; ?>.jpg" />
<div class="mainImage magnify">
<a href="../images/MainImage/<?php echo ucwords($row2[mainImage1]); ?>.jpg" rel="lightbox" title="<?=$row2[name]?>">
<img class="mainImage small" src="../images/MainImage/<?php echo $row2[mainImage1]; ?>.jpg" /></a>
</div>
添加我当前的Javascript:
$('#thumbs').delegate('img', {
click: function(){
$('.mainImage').attr('src',$(this).attr('src').replace('ThumbSelection','MainImage').replace('selectionThumb','mainImage')); //here I replace the src of the Main Image to match the selected thumbnail.
var $this = $(this),
index = $this.index();
$("#thumbs img").removeClass('thumbSelected');
$this.addClass('thumbSelected');
}});
用户可以点击几个拇指。主图在点击其Thumb后加载相应的图片。但是,(用于灯箱)永远不会更改以适应新加载的图片,并且灯箱始终使用相同的图像而不是用户单击的图像。谢谢!