views:

114

answers:

2

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? :-)

+3  A: 
if ($(window).width() < 1024) {
    $('#someElement').hide();
}

or:

$('#someElement').toggle($(window).width() >= 1024);
Darin Dimitrov
So simple, so lovely. :-)
meep
+1  A: 

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"&gt;&lt;/script&gt;
    <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>
jessegavin
This rocks! :-)
meep