1 javascript wordpress jquery twitter-bootstrap-3
我有这段代码,它完美无缺,但我只想将它应用于大屏幕而不是移动设备。任何帮助将不胜感激。
<script>
(function($) {
jQuery(function($) {
$('.navbar .dropdown').hover(function() {
$(this).find('.dropdown-menu').first().stop(true, true).delay(250).slideDown();
}, function() {
$(this).find('.dropdown-menu').first().stop(true, true).delay(100).slideUp();
});
$('.navbar .dropdown > a').click(function() {
location.href = this.href;
});
});
})(jQuery);
</script>Run Code Online (Sandbox Code Playgroud)
尝试这个:
if ( $(window).width() > 739) {
//Add your code for large screen
}
else {
//Add code for small screen
}
Run Code Online (Sandbox Code Playgroud)
编辑:将此应用于您的代码(使用@soloughlin3 建议的调整大小)
$(document).ready(myfunction);
$(window).on('resize',myfunction);
function myfunction() {
if ( $(window).width() > 739) {
$('.navbar .dropdown').hover(function() {
$(this).find('.dropdown-menu').first().stop(true, true).delay(250).slideDown();
}, function() {
$(this).find('.dropdown-menu').first().stop(true, true).delay(100).slideUp();
});
$('.navbar .dropdown > a').click(function() {
location.href = this.href;
});
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
750 次 |
| 最近记录: |