0

I can't seem to get my if statement working. I know that everything inside the if statement works, so would appreciate some help.

$(document).ready(function () {
    if(screen.width > 350) {
        $('#search').hide();
        $('.trigger').click(function () {
            $('#search').slideToggle("500");
        });
    }
});
2
  • Place alert(screen.width); before if statement and tell us what you see. Commented Nov 28, 2011 at 4:44
  • Seems to work fine, maybe let us know what you expect vs what's actually happening. Commented Nov 28, 2011 at 4:47

2 Answers 2

1

try using:

if ($(window).width() > 350) {

or

 if ($(document).width() > 350) {

i hope it helps.

Sign up to request clarification or add additional context in comments.

1 Comment

np, i'm glad it got resolved :) btw, if you like the answer, don't forget to check it off as the answer
1

This returns width of browser viewport:

$(window).width();

This returns width of HTML document:

$(document).width();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.