Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2013
    Posts
    145
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Question window width needs a refresh to detect?!

    hi,

    my code below only works when my browser is refreshed?!

    Code:
    if($(window).width() <= 768){
    alert('hello');
    $('header').hide();
    }
    I would like it to alert('hello'); when the browser is resized?!

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    How about that?

    Code:
    $(document).ready(function() {
      $(window).resize(function() {
        if($(window).width() < 768) {
          alert('hello');
          $('header').hide();
        }
      });
    });

  • Users who have thanked devnull69 for this post:

    jarv81178 (10-08-2013)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •