I'm trying to use media queries to disable float at a certain browser width. This if statement only works if I reload the page for the current size. Is it possible to have jQuery apply the change when the CSS property changes?
if($('.two-column li').css('float') == 'left') {
$('.two-column li').equalHeights();
}
and I'm probably supposed to use $(this) or something on the second $('.two-column li') but I don't know why it doesn't work. I don't know too much about jQuery.
edit:
By default, the style for two-column li is something like
.two-column li {
float: left;
}
and then let's say...
@media only screen and (max-width: 767px) {
.two-column li {
float: none;
}
}
This does work. When the width is below 767px, it stops floating. The ugly jquery I have above seems to work partially. By default, equalheights plugin runs, but when width is below 767px, the plugin does not run. My problem is that whether it runs or not depends on what size the browser was at when the page was loaded. I'm trying to make it dynamic like the media query in a responsive design.
And I called it on document ready.
With the help of more research and a comment below, it is now like this including doc ready... still doesn't do it on resize though, needs refresh.
$(document).ready(function () {
$('.two-column li').filter(function(index) {
return $(this).css('float') != 'none'
}).equalHeights();
});