87,903
社区成员
发帖
与我相关
我的任务
分享
var navbar_Reload = function(){
if(document_Width>= 1080)
{
$(".navbottom li").mouseover(function(){
alert(document_Width);
}
}
$(window).resize(function(){
document_Width = document.body.clientWidth;
navbar_Reload();
});
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
</style>
</head>
<body>
<ul class="navbottom">
<li>xxxxxxxxxxxxx</li>
</ul>
<script type="text/javascript">
$(window).ready(function () {
$(".navbottom li").mouseover(function(){
if (document.body.clientWidth < 1080) return;
console.log("mouseover");
});
$(".navbottom li").mouseleave(function(){
if (document.body.clientWidth < 1080) return;
console.log("mouseleave");
});
});
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
</style>
</head>
<body>
<ul class="navbottom">
<li>xxxxxxxxxxxxx</li>
</ul>
<script type="text/javascript">
var document_Width;
var navbar_Reload = function(){
$(".navbottom li").mouseover(function(){
if (document_Width < 1080) return;
console.log("mouseover",document_Width);
});
$(".navbottom li").mouseleave(function(){
if (document_Width < 1080) return;
console.log("mouseleave",document_Width);
});
}
function onre(){
document_Width = document.body.clientWidth;
}
$(window).resize(onre);
$(window).ready(function () {
navbar_Reload();
onre();
});
</script>
</body>
</html>
[/quote]我又试了一下,还是不起作用,即使在里面加判断条件之后还是不受控制,窗口宽度改变之后只有刷新能恢复正常...可是刷新的话太影响体验了
$(".navbottom li").mouseover(function(){
if(document_Width>= 1080){
alert(document_Width);
}
});
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
</style>
</head>
<body>
<ul class="navbottom">
<li>xxxxxxxxxxxxx</li>
</ul>
<script type="text/javascript">
var document_Width;
var navbar_Reload = function(){
$(".navbottom li").mouseover(function(){
if (document_Width < 1080) return;
console.log("mouseover",document_Width);
});
$(".navbottom li").mouseleave(function(){
if (document_Width < 1080) return;
console.log("mouseleave",document_Width);
});
}
function onre(){
document_Width = document.body.clientWidth;
}
$(window).resize(onre);
$(window).ready(function () {
navbar_Reload();
onre();
});
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> 页面名称 </title>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
</style>
</head>
<body>
<ul class="navbottom">
<li>xxxxxxxxxxxxx</li>
</ul>
<script type="text/javascript">
var navbar_Reload = function(w){
$(".navbottom li").off("mouseover");
if(w >= 1080)
{
$(".navbottom li").mouseover(function(){
alert(w);
});
}
}
function onre(){
var document_Width = document.body.clientWidth;
navbar_Reload(document_Width);
}
$(window).resize(onre);
$(window).ready(onre);
</script>
</body>
</html>