Hello.
Is it possible to detect what width a browser window is and hide an element on page if its lower than 1024?
In JQuery perhaps? :-)
Hello.
Is it possible to detect what width a browser window is and hide an element on page if its lower than 1024?
In JQuery perhaps? :-)
if ($(window).width() < 1024) {
$('#someElement').hide();
}
or:
$('#someElement').toggle($(window).width() >= 1024);
This will show/hide the element when the window resizes
EDIT: Updated to use toggle()
from Darin Dimitrov's answer
<html>
<head>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$(window).bind("resize", function() {
$('#someElement').toggle($(this).width() >= 1024);
}).trigger("resize");
});
</script>
</head>
<body>
<div id="someElement">SOME ELEMENT</div>
</body>
</html>