Rob
Rob

Reputation: 1495

Basic Javascript - Applying to style to two classes

Sorry for the really basic question.

I'm trying to apply two different classed to to two different divs at the same point on scroll.

Currently the JS looks like this

if ( position > 480 && !(docViewBottom >= elemTop)) {
$('#work').css({'position':'fixed', 'top':'0', 'height':'100vh'});
} else {

but how do I add a addition div and style with something like

if ( position > 480 && !(docViewBottom >= elemTop)) {
$('#work').css({'position':'fixed', 'top':'0', 'height':'100vh'}
#workslider {'position: fixed'});
} else {

Upvotes: 0

Views: 55

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82251

To style the both elements with same style:

$('#work,#workslider').css({'position':'fixed', 'top':'0', 'height':'100vh'});

for just setting css position fixed for both:

$('#work,#workslider').css('position','fixed');
$('#work').css({'top':'0', 'height':'100vh'});

Upvotes: 2

Related Questions