jqueryaddclass
这可能很简单,但我是jQuery新手,所以。。。在IE 8中,链接颜色即使在兼容模式下也不会变成粉红色。现在,如果我在firefox上运行它,chrome就可以了。但有一件事让我困惑。如果我在功能中添加一个警报,那么在IE 8中,链接将变为粉红色,并显示消息框。有人能解释一下这是怎么回事吗jqueryaddclass,jquery,Jquery,这可能很简单,但我是jQuery新手,所以。。。在IE 8中,链接颜色即使在兼容模式下也不会变成粉红色。现在,如果我在firefox上运行它,chrome就可以了。但有一件事让我困惑。如果我在功能中添加一个警报,那么在IE 8中,链接将变为粉红色,并显示消息框。有人能解释一下这是怎么回事吗 <%@ Page Title="Home Page" Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inher
<%@ Page Title="Home Page" Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head id="Head1" runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<style type="text/css">
a.over {color:pink;}
</style>
<script type="text/javascript">
$(document).ready(function () {
$("a").mouseover(function () {
$(this).addClass("over");
//alert("mouseOver");
});
$("a").mouseout(function () {
$(this).removeClass("over");
});
});
</script>
</head>
<body>
<form id="Form1" runat="server">
<div>
<a class="" href="#">Link</a>
</div>
</form>
</body>
</html>
我知道我可能只需要在css中添加:hover之类的内容,但这只是一个我无法使用的教科书示例
谢谢尝试添加页面的doctype begging
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
更新
The doctype declaration should be the very first thing in an HTML document, before the <html> tag.
The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in.
The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
尝试添加页面的doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
更新
The doctype declaration should be the very first thing in an HTML document, before the <html> tag.
The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in.
The doctype declaration refers to a Document Type Definition (DTD). The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
我知道您可能没有问这个问题,但仅使用:hover伪类就可以了:
a:hover { color: pink; }
也考虑使用方法和方法:
但我也同意@Kanishka的观点:IE必须使用正确的DOCTYPE,我知道你可能不会问这个问题,但只要使用:hover伪类就行了:
a:hover { color: pink; }
也考虑使用方法和方法:
但我也同意@Kanishka的观点:IE必须使用正确的DOCTYPE我不明白为什么它不起作用。尝试将CSS更改为a.over,a:visted.over,a:link.over{color:pink;},看看是否有区别。对于IE@Kanishka解决方案,我不明白为什么它不起作用。尝试将CSS更改为a.over,a:visted.over,a:link.over{color:pink;},看看是否有区别。对于IE@Kanishka解决方案,我尝试给你一个分数,我得到消息单击此框以取消。。。只是过了糟糕的一天。不管怎么说,这起作用了。现在,你知道为什么这对IE如此重要,以及为什么向代码中添加一个警报可以让它工作吗?我试着给你一个提示,我得到消息单击此框可以忽略。。。只是过了糟糕的一天。不管怎么说,这起作用了。现在,你知道为什么这对IE如此重要,以及为什么向代码中添加一个警报使其工作了吗?谢谢你的悬停功能。我想我读过一些关于鼠标悬停不如鼠标悬停可靠的跨浏览器的文章。但我可能错了。谢谢你的悬停功能。我想我读过一些关于鼠标悬停不如鼠标悬停可靠的跨浏览器的文章。但我可能错了。