您好我有一个jQuery的JavaScript函数, 我只面对Chrome问题,在所有其他浏览器中它运行正常。 问题是元素“change_h2”和“change_p和src没有改变,那些是不起作用的行:
if ((evt.item.image.src) == imgsrc){
document.getElementById("change_h2").innerHTML = "THE TEST BLA";
document.getElementById("change_p").innerHTML = " Lorem22 ipsum22 Lorem 222 ipsum Lorem ipsum Lorem ipsum Lorem ipsum";
document.getElementById("women-eyes1").src = "images/ss2.png";
.............
}
有时它会在镀铬中工作几秒钟,然后停止,
我试图清理缓存,但它仍无效。
这是完整的功能:
$(function () {
var carousel= $('.sky-carousel').carousel({
enableMouseWheel: false,
itemWidth: 135,
itemHeight: 76,
distance: 4,
selectedItemDistance: 15,
selectedItemZoomFactor: 1.4,
unselectedItemZoomFactor:1,
unselectedItemAlpha: 0.5,
motionStartDistance: 150,
topMargin: 14,
/*gradientStartPoint: 0.35,
gradientOverlayColor: "#f5f5f5",
gradientOverlaySize: 190,
reflectionDistance: 1,
reflectionAlpha: 0.35,*/
reflectionVisible: false,
/*reflectionSize: 70,*/
selectByClick: true,
slideSpeed:0.45,
gradientOverlayVisible: false,
/* autoSlideshow: true,
autoSlideshowDelay: 2.5, */
autoSlideshow: true,
autoSlideshowDelay: 2.5
});
var imgsrc = document.getElementById("pic1").getAttribute('src');
var imgsrc2 = document.getElementById("pic2").getAttribute('src');
carousel.on('itemSelected.sc', function (evt) {
if ((evt.item.image.src) == imgsrc){
document.getElementById("change_h2").innerHTML = "THE TEST BLA";
document.getElementById("change_p").innerHTML = " Lorem22 ipsum22 Lorem 222 ipsum Lorem ipsum Lorem ipsum Lorem ipsum";
document.getElementById("women-eyes1").src="images/ss2.png";
} else if((evt.item.image.src) == imgsrc2) {
document.getElementById("change_h2").innerHTML = "THE TEST BLA222";
document.getElementById("change_p").innerHTML = " Lorem22 ipsum22 Lorem 222sum Lore";
document.getElementById("women-eyes1").src="images/ss1.png";
}
document.getElementById("mainImage1").src= (evt.item.image.src);
});
});
这是HTML:
<div class="carousel-inner">
<div class="item active">
<img src="images/dragon_hunter_pic.png" alt="dragon_hunter_pic"
id="mainImage1" >
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-4 col-xl-4 col-md-5 col-xs-5 col-sm-5 ">
<div class="women-margin">
<img src="images/women_3.png" alt="live" id="women-eyes1" >
</div>
</div>
<div class="col-lg-4 col-xl-4 col-md-7 col-xs-7 col-sm-7 ">
<div class="yellow-box">
<h2 id="change_h2">THE DRAGON HUNTER</h2>
<br/>
<p id="change_p"> Lorem ipsum dolor sit amet, consectetur
adipiscing elit, sed do eiusmod tempor incididunt ut labore et
dolor aliqua.
</p>
</div>
</div>
</div>
</div>
<li> <a href="#home"><img src="images/dragon_hunter_pic.png" id="pic1"
alt="" /></a></li>
<li> <a href="#home"><img src="images/betest.png" id="pic2"
alt="" /></a> </li>
调试器没有显示任何错误。