首先声明自己是刚学JQuery,提的问题弱智,大家不要笑$("div+p").addClass("P1");这个表达式是匹配DIV层后的第一个P元素,然后给它加样式P1.可是我用了后怎么也不能匹配..
大家帮忙看看是哪里不对 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.test{
background-color:Red;
color:Red;
}
</style>
<script type="text/javascript" src="jquery-1.3.2.min.js">
</script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$("div+p").addClass("test");
});
//]]>
</script>
</head>
<body>
<div><p>456</p></div>
<form id="form1" runat="server">
<div><p>123</p></div>
<div>
<p>这是第一个加号</p>
<div id="divTest">
<p>我测试+号</p>
</div>
<div><a href="#">test</a><p>这是第二个加号</p></div>
</div>
</form>
</body>
</html>
大家帮忙看看是哪里不对 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.test{
background-color:Red;
color:Red;
}
</style>
<script type="text/javascript" src="jquery-1.3.2.min.js">
</script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$("div+p").addClass("test");
});
//]]>
</script>
</head>
<body>
<div><p>456</p></div>
<form id="form1" runat="server">
<div><p>123</p></div>
<div>
<p>这是第一个加号</p>
<div id="divTest">
<p>我测试+号</p>
</div>
<div><a href="#">test</a><p>这是第二个加号</p></div>
</div>
</form>
</body>
</html>
解决方案 »
- 求JSP+sql数据库学生学籍管理系统
- <求助>根据数组的值,改变checkbox的checked状态。
- JS怎么修改option中显示的名字?
- -moz-user-select怎么用js实现
- asp里怎么调用别的asp页面中的javascript
- 能够给这个flash下载回来的方法送100分(似乎是flv格式的)
- function btnClick(v){document.all.MyText.value=v.value;}的问题
- 能不能在页面初始化时用JavaScript实现Button的disabled效果?
- 聊天室的新数据是怎么追加上去的,(我指的是原数据不变),回答有分!!!
- 如何通过javascript或其他方式调用右键中的目标另存为..的功能
- 简单问题,希望大家帮忙看看
- 请教js能否获取本地文件夹的大小
<head runat="server">
<title>无标题页</title>
<style type="text/css">
.test{
background-color:Red;
color:Red;
}
</style>
<script type="text/javascript" src="jquery-1.3.2.min.js">
</script>
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
$("div+p").addClass("test");
});
//]]>
</script>
</head>
<body>
<div><p>456</p></div>
<!--在这里添加一个p的元素-->
<p>789</p>
<form id="form1" runat="server">
<div><p>123</p></div>
<div>
<p>这是第一个加号</p>
<div id="divTest">
<p>我测试+号</p>
</div>
<div><a href="#">test</a><p>这是第二个加号</p></div>
</div>
</form>
</body>
</html>