imgとタイトル(h3)にクラスを追加して色を変更しようとしています。 .test-shadowにクラスを追加しようとしていますが、h3は動作していません。 .closest/.findに変化する兄弟を試してみましたが、どちらもうまくいきません。アイデア?スクロールの色を変更する
\t /* highlight border of winner */
$('.img-winner').each(function(i){
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height();
/* If the object is completely visible in the window, animate border or box shadow */
if(bottom_of_window > bottom_of_object){
\t \t \t $(this).siblings('.test-shadow:first').addClass('greenit');
\t \t \t $(this).siblings('h3.test-who-us:first').addClass('green');
}
});
<ul class="2-column center test-images">
<li>
<h3 class="test-who-us">Medsite Medical</h3>
<div class="test-img">
<img class="img-winner" src="/wp-content/uploads/2016/07/test-desktop-us.png" alt="test-desktop">
<div class="test-shadow"></div>
</div>
</li>
<li>
<h3 class="test-who-them">Top competitor</h3>
<div class="test-img">
<img class="img-loser" src="/wp-content/uploads/2016/07/test-desktop-them.png" alt="test-desktop-competitors">
<div class="test-shadow"></div>
</div>
</li>
</ul>
.closest( 'リー') '$(this)を使用してみてください。( 'H3')を見つける' – Mottie
や '$(この).parent( '李')を使用してみてください。( 'H3' が見つかり) ' – daymosik
または' $(this).parent()。兄弟( 'h3.test-who-us:first') ' – Iceman