3

I have hover state on my JQuery which is this:

$('.navigation a').hover(
        function () {
            $(this).next('span').show();
        },
        function () {
            $(this).next('span').hide();
        }
    );

Now I want that hover state to disable whenever the user's screen resolution is 769px or lower.

3
  • So what is your particular question? You don't know how to get screen width? How to compare it with static value? Commented Jun 29, 2012 at 5:25
  • 1
    Do you mean you want the hover to disable and re-enable dynamically if the user changes the resolution while viewing your page (overkill, in my opinion), or just not bind the hover at all if the resolution is under your threshold at page load? Either way, try window.screen.width. Commented Jun 29, 2012 at 5:31
  • Just not bind the hover if the resolution is 769px and lower. Commented Jun 29, 2012 at 5:36

1 Answer 1

6

I found the answer.

if ( $(window).width() > 769) {
$('.navigation a').hover(
        function () {
            $(this).next('span').show();
        },
        function () {
            $(this).next('span').hide();
        }
    );
}
Sign up to request clarification or add additional context in comments.

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.