滑块中的图像宽度不同。字幕是否可以与图像宽度相同? 试图动态获取图像宽度,但它总是返回0:
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
jssor_slider1.$On($JssorSlider$.$EVT_PARK, function (slideIndex, fromIndex) {
var _imgW = $('#img_' + slideIndex);
$(".captionBlack").css("width", _imgW.innerWidth());
});
每个图片都分配了一个唯一ID。在运行时检查dom显示宽度,var _imgW返回正确的元素,但上面代码段中的宽度始终为零
--- --- EDIT
- 标记 -
<div id="slide_@i">
<img id="img_@i" u="image" src="@roomAdvertImage" alt="@altImage" title="@altImage"/>
<div u="thumb">
<div style="width: 100%; height: 100%; background-image: url(@roomAdvertImage); background-size: contain; background-repeat: no-repeat; background-position: center center;"></div> </div>
@if (userPhotoTitle != null && userPhotoTitle.Length > 0){
<div u=caption t="*" class="captionBlack" style="position:absolute; left:0px; top: 30px; width:100%; height:40px;">@userPhotoTitle</div>
}
</div>