Responsive: two different toggles on same element

Posted by Mathijs Delva on Stack Overflow See other posts from Stack Overflow or by Mathijs Delva
Published on 2014-08-21T10:13:30Z Indexed on 2014/08/21 10:20 UTC
Read the original article Hit count: 160

Filed under:
|

I'm having difficulties with the following problem. For a responsive website, i need to use the same toggle element for both a toggle system for one window width, and another toggle system for a second window width. I have the following snippets:

1.A simple hover for a language dropdown, which should be executed for resolutions greater than 980px.

$('#clickme').hover(function() {
    $(this).parent().find("#select-language").show();
        $(this).find("> a span").css({"opacity":"0.5"});
    }, function() {
        $(this).parent().find("#select-language").hide();
    $(this).find("> a span").css({"opacity":"1"});
});

2.A simple click for the same language toggle, which should be executed for resolutions smaller than 980px.

jQuery('#clickme').click(function() {
        jQuery("#select-language-mobile").slideToggle("fast");
    });

I need to nest these two, so that when the user is viewing the website in one resolution, the click function with be fired, and in the other case the hover function.

Can anybody help me with this?

PS: I'm sorry, but the code blocks don't seem to work at the moment.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about toggle