<!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="Content-Type" content="text/html; charset=gb2312" />
<title>jquery</title>
<style>
<!--
.menuConment{ color:red; font-size:24px; text-decoration:none;}
-->
</style><script language="javascript" src="xtcsh/js/jquery.min.js"></script><script language="javascript">
$(document).ready(function(){
$("#top a").addClass("menuConment");
})
</script></head>
<body>
<div id="top">
<div><a href="">php</a></div>
<div><a href="">jquery</a></div>
</div>
</body>
</html>
以上代码,在IE中没有反映,在其他浏览器正常,不知道问题出在哪里?
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>jquery</title>
<style>
<!--
.menuConment{ color:red; font-size:24px; text-decoration:none;}
-->
</style><script language="javascript" src="xtcsh/js/jquery.min.js"></script><script language="javascript">
$(document).ready(function(){
$("#top a").addClass("menuConment");
})
</script></head>
<body>
<div id="top">
<div><a href="">php</a></div>
<div><a href="">jquery</a></div>
</div>
</body>
</html>
以上代码,在IE中没有反映,在其他浏览器正常,不知道问题出在哪里?
$(document).ready(function(){
$("#top a").addClass("menuConment");
})
</script>
你最好放在最后,或者使用window,onload=function()
{$("#top a").addClass("menuConment");
}有时候放在页面是不行的
<script language="javascript" src="xtcsh/js/myjs.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>你其他的看不出有导致出问题的地方。我也只能严重怀疑你这个文件的正确性或是它编码格式啥的了
$(document).ready(function(){
alert("执行了吗?")
$("#top a").addClass("menuConment");
})
</script>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<script type="text/javascript" src="./jquery.js"></script>
<style>
<!--
.menuConment{ color:red; font-size:24px; text-decoration:none;}
-->
</style>
<script type="text/javascript">
$(document).ready(function(){
$("#top a").addClass("menuConment");
})
</script>
</head>
<body>
<div id="top">
<div><a href="">php</a></div>
<div><a href="">jquery</a></div>
</div>
</body>
</html>我这是好的,你看看ie左下角有没有什么提示
不好意思,可以了。
把
<script language="javascript" src="xtcsh/js/jquery.min.js"></script>
换成
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>
就可以了。
就不行呢,问题在哪里?
<script type="text/javascript">
$(function () {
$("#top a").addClass("menuConment");
});</script>
而且IE中对于那些没有加;或,结尾,没有正确闭合标签都会没有效果
要指定type属性。<style type="text/css">