admin管理员组文章数量:1279015
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');
});
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');
});
Share
Improve this question
edited Jul 6, 2015 at 20:47
Mohammad Kashif
asked Feb 8, 2015 at 8:38
Mohammad KashifMohammad Kashif
1031 gold badge1 silver badge10 bronze badges
2
-
You want to hide
#my-btnn
or you want click on it to do nothing? – dfsq Commented Feb 8, 2015 at 8:42 - i want this javascript function only in mobile device 767px while i want disable this javascript function in desktop site. – Mohammad Kashif Commented Feb 8, 2015 at 8:44
2 Answers
Reset to default 9You 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');
}
});
You can bind your click by checking your resolution. Use onResize and check by screen.width
$(window).resize(function() {
if (screen.width <= 767) {
$('#my-btnn').bind('click', function () {
$('#mobile-login').hide();
$('#user-settings').slideToggle('fast');
});
}
});
And you can check if you were binded early.
Or you can just to add this checking in onReload
本文标签: javascriptjava script functionality only in mobile deviceStack Overflow
版权声明:本文标题:javascript - java script functionality only in mobile device - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741219631a2360716.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论