0
我想通過jQuery索引來更改元素的css。jQuery按索引更改css
$(".switcher span").click(function() {
var galleryIndex = $(this).index();
$('.wrapper .gallery').eq(galleryIndex).css("background", "red");
});
<div class="switcher">
<span>Switch 0</span>
<span>Switch 1</span>
</div>
<div class="wrapper">
<div class="gallery">GALLERY 0</div>
<div class="gallery">GALLERY 1</div>
</div>
的jQuery得到的.switcher span
罰款指標,但似乎PF畫廊指數沒有加載。到目前爲止它不工作。
工作對我很好......難道份額可執行代碼段.. .. – Rayon
工作正常https://jsfiddle.net/nu4ngh31/ – Satpal