62,272
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset=utf-8 />
<title>Hide Demo</title>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
function display(id)
{
document.getElementById(id).style.display="block";
}
function hide(id)
{
document.getElementById(id).style.display = "none";
}
</script>
<style type="text/css">
.con
{
margin-left:auto;
margin-right:auto;
background-color: #FF00F7;
width: 1000px;
height: 1000px;
}
.selfat
{
margin-left:auto;
margin-right:auto;
background-color: #E9E9E4;
width: 1000px;
height: 30px;
padding-bottom: 0px;
}
.seldiv
{
width: 136px;
height: 110px;
border: 1px solid #EF00FF;
position: relative;
float: right;
margin-right: -41px;
margin-top: 30px;
z-index: 10;
}
.seldiv ul
{
list-style-type:none;
background-color: White;
border: 1px solid #00A1FF;
margin-top: 0px;
}
.seldiv ul li
{
text-align:center;
display: block;
font-family: 微软雅黑;
font-size: 15px;
font-weight: 500;
border: 1px solid #EFFF00;
width: 132px;
height: 34px;
margin-left: -40px;
}
.seldiv ul li a
{
line-height: 34px;
}
.selligreen a
{
color:Green;
}
.selligreen:hover
{
background-color:Green;
cursor: pointer;
}
.selligreen:hover a
{
color:white;
}
.selliblue a
{
color:Blue;
}
.selliblue:hover
{
background-color:Blue;
cursor: pointer;
}
.selliblue:hover a
{
color:white;
}
.sellired a
{
color:Red;
}
.sellired:hover
{
background-color:Red;
cursor: pointer;
}
.sellired:hover a
{
color:white;
}
.selbtn
{
float: right;
background-color: #00FFD6;
border: 0px;
height: 100%;
width: 40px;
text-align: center;
}
</style>
</head>
<body>
<div class="selfat">
<a>母版页</a>
<input type="button" id="btntheme" runat="server" class="selbtn" onclick="display('divtheme')" value="color"/>
<div id="divtheme" style="display: none;" class="seldiv" >
<ul>
<li class="selligreen" ><a>green</a></li>
<li class="selliblue" ><a>blue</a></li>
<li class="sellired" ><a>red</a></li>
</ul>
</div>
</div>
<div class="con">
<a>内容页</a>
</div>
</body>
</html>
我再讲一下。我那段JQ和JS:
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
function hide(id)
{
document.getElementById(id).style.display = "none";
}
在Demo里我没有用到hide()哦,我只是写出来没有删而已,我的意思是:
1、一开始我打算用 JS 写,就写了 hide(),打算用 <div****mouseout ="hide(divtheme)"> 来实现我的功能,可惜不行,也试过其他很复杂的办法,依旧行不通
2、没办法为了交货我只能用那段 JQ 了($(document).ready(function())
3、现在我想不通,为什么 JQ 能实现得那么完美,而我用 JS 写不出来呢,所以我现在想问的是如何用 JS 完整地实现 JQ 的效果?[/quote]
哦哦,您好像有点误解我的意思了,我上面的回复有提到
我再讲一下。我那段JQ和JS:
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
function hide(id)
{
document.getElementById(id).style.display = "none";
}
在Demo里我没有用到hide()哦,我只是写出来没有删而已,我的意思是:
1、一开始我打算用 JS 写,就写了 hide(),打算用 <div****mouseout ="hide(divtheme)"> 来实现我的功能,可惜不行,也试过其他很复杂的办法,依旧行不通
2、没办法为了交货我只能用那段 JQ 了($(document).ready(function())
3、现在我想不通,为什么 JQ 能实现得那么完美,而我用 JS 写不出来呢,所以我现在想问的是如何用 JS 完整地实现 JQ 的效果?[/quote]
我改了一下
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset=utf-8 />
<title>Hide Demo</title>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
var display =function(id)
{
alert(222)
document.getElementById(id).style.display="block";
}
function hide(id)
{
document.getElementById(id).style.display = "none";
}
</script>
<style type="text/css">
.con
{
margin-left:auto;
margin-right:auto;
background-color: #FF00F7;
width: 1000px;
height: 1000px;
}
.selfat
{
margin-left:auto;
margin-right:auto;
background-color: #E9E9E4;
width: 1000px;
height: 30px;
padding-bottom: 0px;
}
.seldiv
{
width: 136px;
height: 110px;
border: 1px solid #EF00FF;
position: relative;
float: right;
margin-right: -41px;
margin-top: 30px;
z-index: 10;
}
.seldiv ul
{
list-style-type:none;
background-color: White;
border: 1px solid #00A1FF;
margin-top: 0px;
}
.seldiv ul li
{
text-align:center;
display: block;
font-family: 微软雅黑;
font-size: 15px;
font-weight: 500;
border: 1px solid #EFFF00;
width: 132px;
height: 34px;
margin-left: -40px;
}
.seldiv ul li a
{
line-height: 34px;
}
.selligreen a
{
color:Green;
}
.selligreen:hover
{
background-color:Green;
cursor: pointer;
}
.selligreen:hover a
{
color:white;
}
.selliblue a
{
color:Blue;
}
.selliblue:hover
{
background-color:Blue;
cursor: pointer;
}
.selliblue:hover a
{
color:white;
}
.sellired a
{
color:Red;
}
.sellired:hover
{
background-color:Red;
cursor: pointer;
}
.sellired:hover a
{
color:white;
}
.selbtn
{
float: right;
background-color: #00FFD6;
border: 0px;
height: 100%;
width: 40px;
text-align: center;
}
</style>
</head>
<body>
<div class="selfat">
<a>母版页</a>
<input type="button" id="btntheme" runat="server" class="selbtn" onclick="display('divtheme')" value="color"/>
<div id="divtheme" class="seldiv" >
<ul>
<li class="selligreen" ><a>green</a></li>
<li class="selliblue" ><a>blue</a></li>
<li class="sellired" ><a>red</a></li>
</ul>
</div>
</div>
<div class="con">
<a>内容页</a>
</div>
</body>
</html>
</body>
</html>[/quote]
第二种
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset=utf-8 />
<title>Hide Demo</title>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<style type="text/css">
.con
{
margin-left:auto;
margin-right:auto;
background-color: #FF00F7;
width: 1000px;
height: 1000px;
}
.selfat
{
margin-left:auto;
margin-right:auto;
background-color: #E9E9E4;
width: 1000px;
height: 30px;
padding-bottom: 0px;
}
.seldiv
{
width: 136px;
height: 110px;
border: 1px solid #EF00FF;
position: relative;
float: right;
margin-right: -41px;
margin-top: 30px;
z-index: 10;
}
.seldiv ul
{
list-style-type:none;
background-color: White;
border: 1px solid #00A1FF;
margin-top: 0px;
}
.seldiv ul li
{
text-align:center;
display: block;
font-family: 微软雅黑;
font-size: 15px;
font-weight: 500;
border: 1px solid #EFFF00;
width: 132px;
height: 34px;
margin-left: -40px;
}
.seldiv ul li a
{
line-height: 34px;
}
.selligreen a
{
color:Green;
}
.selligreen:hover
{
background-color:Green;
cursor: pointer;
}
.selligreen:hover a
{
color:white;
}
.selliblue a
{
color:Blue;
}
.selliblue:hover
{
background-color:Blue;
cursor: pointer;
}
.selliblue:hover a
{
color:white;
}
.sellired a
{
color:Red;
}
.sellired:hover
{
background-color:Red;
cursor: pointer;
}
.sellired:hover a
{
color:white;
}
.selbtn
{
float: right;
background-color: #00FFD6;
border: 0px;
height: 100%;
width: 40px;
text-align: center;
}
</style>
</head>
<body>
<div class="selfat">
<a>母版页</a>
<input type="button" id="btntheme" runat="server" class="selbtn" onclick="display('divtheme')" value="color"/>
<div id="divtheme" class="seldiv" >
<ul>
<li class="selligreen" ><a>green</a></li>
<li class="selliblue" ><a>blue</a></li>
<li class="sellired" ><a>red</a></li>
</ul>
</div>
</div>
<div class="con">
<a>内容页</a>
</div>
</body>
<script type="text/javascript">
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
function display(id)
{
alert(222)
document.getElementById(id).style.display="block";
}
function hide(id)
{
document.getElementById(id).style.display = "none";
}
</script>
</html>
我再讲一下。我那段JQ和JS:
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
function hide(id)
{
document.getElementById(id).style.display = "none";
}
在Demo里我没有用到hide()哦,我只是写出来没有删而已,我的意思是:
1、一开始我打算用 JS 写,就写了 hide(),打算用 <div****mouseout ="hide(divtheme)"> 来实现我的功能,可惜不行,也试过其他很复杂的办法,依旧行不通
2、没办法为了交货我只能用那段 JQ 了($(document).ready(function())
3、现在我想不通,为什么 JQ 能实现得那么完美,而我用 JS 写不出来呢,所以我现在想问的是如何用 JS 完整地实现 JQ 的效果?[/quote]
哦哦,您好像有点误解我的意思了,我上面的回复有提到
我再讲一下。我那段JQ和JS:
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
function hide(id)
{
document.getElementById(id).style.display = "none";
}
在Demo里我没有用到hide()哦,我只是写出来没有删而已,我的意思是:
1、一开始我打算用 JS 写,就写了 hide(),打算用 <div****mouseout ="hide(divtheme)"> 来实现我的功能,可惜不行,也试过其他很复杂的办法,依旧行不通
2、没办法为了交货我只能用那段 JQ 了($(document).ready(function())
3、现在我想不通,为什么 JQ 能实现得那么完美,而我用 JS 写不出来呢,所以我现在想问的是如何用 JS 完整地实现 JQ 的效果?[/quote]
我改了一下
<!DOCTYPE html>
<html lang="zh-cmn-Hans">
<head>
<meta charset=utf-8 />
<title>Hide Demo</title>
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
var display =function(id)
{
alert(222)
document.getElementById(id).style.display="block";
}
function hide(id)
{
document.getElementById(id).style.display = "none";
}
</script>
<style type="text/css">
.con
{
margin-left:auto;
margin-right:auto;
background-color: #FF00F7;
width: 1000px;
height: 1000px;
}
.selfat
{
margin-left:auto;
margin-right:auto;
background-color: #E9E9E4;
width: 1000px;
height: 30px;
padding-bottom: 0px;
}
.seldiv
{
width: 136px;
height: 110px;
border: 1px solid #EF00FF;
position: relative;
float: right;
margin-right: -41px;
margin-top: 30px;
z-index: 10;
}
.seldiv ul
{
list-style-type:none;
background-color: White;
border: 1px solid #00A1FF;
margin-top: 0px;
}
.seldiv ul li
{
text-align:center;
display: block;
font-family: 微软雅黑;
font-size: 15px;
font-weight: 500;
border: 1px solid #EFFF00;
width: 132px;
height: 34px;
margin-left: -40px;
}
.seldiv ul li a
{
line-height: 34px;
}
.selligreen a
{
color:Green;
}
.selligreen:hover
{
background-color:Green;
cursor: pointer;
}
.selligreen:hover a
{
color:white;
}
.selliblue a
{
color:Blue;
}
.selliblue:hover
{
background-color:Blue;
cursor: pointer;
}
.selliblue:hover a
{
color:white;
}
.sellired a
{
color:Red;
}
.sellired:hover
{
background-color:Red;
cursor: pointer;
}
.sellired:hover a
{
color:white;
}
.selbtn
{
float: right;
background-color: #00FFD6;
border: 0px;
height: 100%;
width: 40px;
text-align: center;
}
</style>
</head>
<body>
<div class="selfat">
<a>母版页</a>
<input type="button" id="btntheme" runat="server" class="selbtn" onclick="display('divtheme')" value="color"/>
<div id="divtheme" class="seldiv" >
<ul>
<li class="selligreen" ><a>green</a></li>
<li class="selliblue" ><a>blue</a></li>
<li class="sellired" ><a>red</a></li>
</ul>
</div>
</div>
<div class="con">
<a>内容页</a>
</div>
</body>
</html>
</body>
</html>
我再讲一下。我那段JQ和JS:
$(document).ready(function(){
$("#divtheme").mouseleave(function(){
$("#divtheme").hide();
});
});
function hide(id)
{
document.getElementById(id).style.display = "none";
}
在Demo里我没有用到hide()哦,我只是写出来没有删而已,我的意思是:
1、一开始我打算用 JS 写,就写了 hide(),打算用 <div****mouseout ="hide(divtheme)"> 来实现我的功能,可惜不行,也试过其他很复杂的办法,依旧行不通
2、没办法为了交货我只能用那段 JQ 了($(document).ready(function())
3、现在我想不通,为什么 JQ 能实现得那么完美,而我用 JS 写不出来呢,所以我现在想问的是如何用 JS 完整地实现 JQ 的效果?<div id="divtheme" style="display: none;" class="seldiv" >
加上了 runat="server" 之后为什么在 JavaScript 里就找不到它的 ID 呢?
就是 Demo 里面的
function hide(id)
{
document.getElementById(id).style.display = "none";
}
尽管我没用到那一句话,但是我想不通为什么回交服务器后前台 JS 会连这个标签的 ID 都找不到(报错document.getElementById(id)没有 style 值)
还有,JQuery 不都是 JS 写的嘛,为什么 JQ 的 mouseleave 事件比 JS 的 mouseout 精确?请问我可以怎样继续深究过中的原由?