Hide Div depending on screen res

Discussion in 'Programming' started by Rivmedia, Mar 15, 2012.

  1. #1
    Can anyone see whats wrong with this Jquery, I found it around the web somewhere but i cant get it working :

    
    <script> 
    $(document).ready(function() {
    
    if ((screen.width>1024)) {
    
    $(".advert").css('display', 'block'); 
    }
    elseif ((screen.width<=1024))  {
    
    $(".advert").css('display', 'none'); 
    }
    });
    </script>
    Code (markup):
    Basically the idea is to show an advert ( inside a div called advert ) but for it only to display on screen resolutions above 1025px wide. I dont want to use CSS3 to do it because its not compatible with older IE browesers so Jquery seems the best option with some people blocking Javascript too.

    Any idea's ?
     
    Rivmedia, Mar 15, 2012 IP
  2. Rivmedia

    Rivmedia Notable Member

    Messages:
    2,306
    Likes Received:
    70
    Best Answers:
    0
    Trophy Points:
    210
    #2
    Anyone ?.....
     
    Rivmedia, Mar 16, 2012 IP
  3. mrandre

    mrandre Peon

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    you missing part of the script that set $(document).ready(function() with any data...
     
    mrandre, Apr 1, 2012 IP