Jquery悬停效果在IE中不起作用 [英] Jquery Hover Effect Doesn't Work in IE

查看:67
本文介绍了Jquery悬停效果在IE中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

html 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>Kentucky Appalachian Rural Rehabilitation Network</title>
</head>
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<script type="text/javascript" src="jquery.js">
</script>
<style type="text/css">


</style>
<script type="text/javascript">
$(document).ready(function () {
$('#nav li').hover(
function () {
//show submenu
$('ul', this).animate({opacity: "show", }, "slow");

},
function () {
//hide submenu
$('ul', this).fadeOut(250);

}
);


})
</script>
<body><div id="centerColumn">
    <div id="header"></div>

<input type="hidden" name="arav" /><ul id="nav">
<li> <a href="#">Home</a>
</li>
<li> <a href="#">Who We Are</a>
</li>
<li> <a href="#">Other box</a>
<ul>
<li><a href="#">Menu</a></li>
<li><a href="#">Menu</a></li>
<li><a href="#">Menu</a></li>
</ul>
</li>
<li> <a href="#">Menu</a>
<ul>
<li><a href="#">Menu</a></li>
<li><a href="#">Menu</a></li>
<li><a href="#">Menu</a></li>
</ul>
</li>
<li> <a href="#">Menu</a>
<ul>
<li><a href="#">State Level</a></li>
<li><a href="#">National Level</a></li>
<li><a href="#">Community Level</a></li>
</ul>
</li>

<li> <a href="#">Research</a></li>

<li> <a href="#">Contact Us</a>
</li>
</ul>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<div class="container">





<div id="footer">
    Footer<a href="#"/>
        </div></div></div></body></html>

CSS

body {
margin:1em;
padding:0;
height:100%;
background-color:#cccccc;
color:#000000;  
text-align:center;
font-family:Arial, Helvetica, sans-serif;
font-size:1em;
border-style: thin;
}

.img{
    float right;
    padding-left: 3em;
    border:thin black ;

}
#reg{font-family:"Palatino Linotype";


}

#centerColumn {
    margin: 0 auto;
    padding: 1em;
    width: 50em;
    text-align: left;
    vertical-align: bottom;
    background-color: #ffffff;
    border: 1px solid #999999;
}


#header {
    border-style: thin;
    background-position: center;
    margin: -1em -1em 0 -1em;
    padding: 0 0 0 0;
    height: 15.5em;
    background-color: #ffffff;

    background-attachment: scroll;
background-repeat:no-repeat; 

}


#footer {
position:relative;
bottom:0;
margin:4em 0 0 0;
padding: 1em 1em 1em 1em;
height:5em;
line-height:4em;
text-align:center;
font-size:.8em;
background-color:#cccccc;
border-top:1px solid #999999;
}

/*****remove the list style****/

#nav {
margin:0;
padding:0;
list-style:none;
}

/*****LI display inline *****/
#nav li {
float:left;
display:block;
width:7em;
background:#0063dc;
position:relative;
z-index:500;
margin:0 1px;
}

/*****parent menu*****/
#nav li a {
display:block;
padding:5px 5px 5px 5px;

font-weight:700;
height:38px;
text-decoration:none;
color:#696969;
text-align:center;
color:#ffeecc;
}

#nav li a:hover
{
color:#eeeeee;
}

/* style for default selected value */ #nav a.selected {
color:#6699FF;
}
/* submenu */ #nav ul
{
position:absolute;
left:0;
display:none;
margin:0 0 0 -1px;
padding:0;
list-style:none;
}

#nav ul li
{
width:7em;
float:left;
overflow:hidden;

border-top:1px solid #eeeeee;
}

/* display block will make the link fill the whole area of LI */
 #nav ul a
{
display:block;
height:32px;
padding: 7px 4px;
color:white;
}

#nav ul a:hover
{
text-decoration:none;
padding-left:none;
}


推荐答案

尝试删除悬空逗号:

$('ul', this).animate({opacity: "show", }, "slow");

所以它是:

$('ul', this).animate({opacity: "show"}, "slow");

如果它不起作用,请确保IE没有以怪癖模式呈现页面或通过以下内容启动HML来使用旧的渲染引擎:

If it doesn't work then make sure that IE isn't rendering your page in quirks mode or using old rendering engine by starting your HML with something like this:

<!doctype html>
<html lang="en-us">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=Edge">

这篇关于Jquery悬停效果在IE中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆