如果“alt”在“span”内,我需要更改以下脚本
function setNavi( $c, $i ) {
var title = $i.attr( 'alt' );
$('#title').text( title );
var current = $c.triggerHandler( 'currentPosition' );
$('#pagenumber span').text( current+1 );
}
$(function() {
$('#carousel').carouFredSel({
debug: true,
responsive: true,
circular: false,
auto: true,
prev: '#prev',
next: '#next',
items: {
visible: 1,
width: 200,
height: '66%'
},
scroll: {
onBefore: function( $oI, $nI ) {
setNavi( $(this), $nI );
}
},
onCreate: function( $vI ) {
setNavi( $(this), $vI );
}
});
html:
<div id="carousel">
<span id="1"><img src="images/someimage.jpg" alt="sometitle" /></span>
<span id="2"><img src="images/someimage2.jpg" alt="sometitle2" /></span>
</div>
<div id="navi">
<p id="pagenumber">Now showing image <span></span> of 7.</p>
<p id="title"></p>
</div>
页码显示正确,但图像标题显示不正确。也尝试使用'title'而不是'alt',但它仍然导致空白标题。