jquery - 调整窗口大小不适用于 JQuery 函数 - 需要刷新窗口
问题描述
我正在设计一个响应式网站,并且有一些 JQuery 功能需要适应网站窗口的大小调整。但是,由于某些原因,某些功能无法调整。
这是一个函数的例子:
function navigate(bottom, top, topbottom, position) {
$(document).on("mouseleave", top, function() {
if ($(bottom).is(':visible')) {
} else {
$(bottom).show();
}
if ($(bottom).is(":hover")) {
} else {
$(bottom).hide();
}
});
$(document).on("mouseleave", bottom, function() {
if ($(top).is(":hover")) {
} else {
$(bottom).hide();
}
});
var width = $(window).width();
if (width <= 768) {
$(document).on("mouseover", top, function() {
var top_2 = 50;
$(bottom).show();
$(".bottom_navigation").css({"top": top_2 * (position + 1)})
});
} else if (width > 768) {
$(document).on("mouseover", top, function() {
var left = $(top).width();
$(bottom).show();
$(".bottom_navigation").css({"left": left * position})
});
}
}
我也尝试过这样的事情:
$(window).on("resize", function() {
//function here!
});
任何人都可以提出解释,以便我理解这种现象并可能提出解决方案吗?
解决方案
推荐阅读
- delphi - 在哪里可以找到 System.Val 的实现?
- python - 如何在 Python 中使用 stdout 的内容?
- node.js - Passport + Sequelize 不保存 req.user
- typescript - 什么是打字稿功能?
- r - 安装包后出错(“tseries”)
- sql - 在另一个表中按计数排序
- woocommerce - 使用颤振和 woocommerce API 在滑块中显示产品的所有图像
- php - 使用 pusher 时如何修复 Laravel 5.7 中的“/broadcasting/auth 401 (Unauthorized)”错误
- python - 如何将列表值添加到 JSON 文件中
- ruby - 通过 Ruby git gem 读取存储库源代码文件?