Reputation: 3469
I have the following script which (i want it to) adds '.shrink' class to quarter-circle class div.
<script>
$(function(){
var shrinkHeader = 50;
$(window).scroll(function() {
var scroll = getCurrentScroll();
if ( scroll >= shrinkHeader ) {
$('quarter-circle').addClass('shrink');
}
else {
$('quarter-circle').removeClass('shrink');
}
});
function getCurrentScroll() {
return window.pageYOffset || document.documentElement.scrollTop;
}
});
</script>
<div class="quarter-circle"></div>
but It doesn't target it, not sure why.
EDIT- trying to apply this when class is added
css
.quarter-circle.shrink {
height: 75px;
width: 75px;
}
Upvotes: 0
Views: 49
Reputation: 1360
Class selector is .(dot) not empty character.
So $('.quarter-circle')
is the answer.
edit:
Your div.quarter-circle
has no content and width and height aren't specified(so 0x0px size) I made example fiddle for help. check it out.
fiddle : http://jsfiddle.net/9k4hk57a/
Upvotes: 2
Reputation: 3429
you can try this one:
<script>
$(function(){
var shrinkHeader = 50;
$(window).scroll(function() {
var scroll = getCurrentScroll();
if ( scroll >= shrinkHeader ) {
$('.quarter-circle').addClass('shrink');
}
else {
$('.quarter-circle').removeClass('shrink');
}
});
</script>
<div class="quarter-circle"></div>
Upvotes: 0
Reputation: 409
You should select your element by class using class selector
$('.quarter-circle').removeClass('shrink');
Here is the jQuery doc
Upvotes: 1