Tell me more ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I need some help with a Zen subtheme using responsive-sidebars.css I have some javascript that I only want to run if the screen is bigger than 480px. The javascript is:

(function ($) {
        jQuery(document).ready(function(){
         $('#selllink').trigger("click");
       });
    })

I am not sure how I would restrict this. Many Thanks Julie

share|improve this question

1 Answer

You can deetect the screen size in Vanilla JS or jQuery. In jQuery you can use height() and width() to get screen size. So you can try this

jQuery(document).ready(function(){
  if($(window).width() > 480){
    $('#selllink').trigger("click");
  }
});

You could also use resize() to check for window resize event.

share|improve this answer
1  
Thank you so much for that it works a treat – julie Mar 31 at 16:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.