目前这确实有效,除了slide.src未定义,因为默认情况下slide.src首先查找图像src标记,但图像src标记现在位于div属性中。
那么如何更改javascript + slide.src +以获取(或获取)div属性中的图像。
查看
<div id="properties">
<?php foreach($search_results->result() as $row) :?>
<div id="<?=$row->mls_listing_id?>"><br>
Listing ID : <?=$row->mls_listing_id?><br>
State: <?=$row->sale_price?><br>
State: <?=$row->mls_state_code?><br>
MLS Office: <?=$row->mls_office_name?><br>
Office Number: <?=$row->mls_office_phone?><br>
Photo: **<img src="<?=$row->photo_url?>" width="175" height="137" /**><br>
</div><!--END specific id div -->
<?php endforeach; ?>
</div><!--End Properties DIV -->
的javascript
$('#properties')
.before('<ul id="propnav">')
.cycle({
fx: 'scrollHorz',
next:'#next',
prev:'#prev',
pager: '#propnav',
delay: -1000 ,
// callback fn that creates a thumbnail to use as pager anchor
pagerAnchorBuilder: function(idx, slide) {
return '<li><a href="#">**<img src="' + slide.src + '"** width="50" height="50" /></a></li>';
}
});
答案 0 :(得分:1)
要获取div幻灯片中包含的图像,您需要使用:$(slide).children('img').attr('src')
这是完整的代码:
$('#properties')
.before('<ul id="propnav">')
.cycle({
fx: 'scrollHorz',
next:'#next',
prev:'#prev',
pager: '#propnav',
delay: -1000 ,
// callback fn that creates a thumbnail to use as pager anchor
pagerAnchorBuilder: function(idx, slide) {
return '<li><a href="#">**<img src="' + $(slide).children('img').attr('src') + '"** width="50" height="50" /></a></li>';
}
});
答案 1 :(得分:0)
非常感谢何塞!我需要同样的东西,但我的情况更糟;)
$(slide).children('div').children('span').children('a').children('img').attr('src')