Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java script functionality only in mobile device

I want java script functionality only in mobile device 767px. This is my code

$('#my-btnn').click(function () {
    $('#mobile-login').hide();
    $('#user-settings').slideToggle('fast');
});
like image 781
Mohammad Kashif Avatar asked Mar 18 '23 03:03

Mohammad Kashif


1 Answers

You can simply check window width in order to determine if function should work or not:

$('#my-btnn').click(function () {
    if ($(window).width() < 767) {
        $('#mobile-login').hide();
        $('#user-settings').slideToggle('fast');
    }
});
like image 168
dfsq Avatar answered Apr 02 '23 10:04

dfsq