$(“p”).next(“.selected)只返回 [<p class=”selected”>And Again</p> ]一个对象
prev () prev (expr) 参照next理解
not(el) not(expr) 从jQuery对象中移出匹配的对象,el为dom元素,expr为jQuery表达式。
<p>one</p><p id=”a”>two</p>
<a href=”#” onclick=”js()”>jQuery</a>jQuery代码及功能:
function js(){
alert($(“p”).not(document.getElementById(“a”)).html());
alert($(“p”).not(“#a”).html());
}$(“p”)由两个对象,排除后的对象为[<p>one</p> ]siblings () siblings (expr) jquery匹配对象中其它兄弟级别的对象
<p>one</p>
<div>
<p id=”a”>two</p>
</div>
<a href=”#” onclick=”js()”>jQuery</a>jQuery代码及功能:
function js(){
alert($(“div”).siblings().eq(1).html());
}$(“div”).siblings()的结果实返回两个对象[<p>one</p>,<a href=”#” onclick=”js()”>jQuery</a> ]
alert($(“div”).siblings(“a”)返回一个对象[<a href=”#” onclick=”js()”>jQuery</a> ]其他
addClass(class) 为匹配对象添加一个class样式
removeClass (class) 将第一个匹配对象的某个class样式移出
attr (name) 获取第一个匹配对象的属性
<img src=”test.jpg”/><a href=”#” onclick=”js()”>jQuery</a> jQuery代码及功能:
function js(){
alert($(“img”).attr(“src”));
}返回test.jpg
attr (prop) 为第一个匹配对象的设置属性,prop为hash对象,用于为某对象批量添加众多属性
<img/><a href=”#” onclick=”js()”>jQuery</a>jQuery代码及功能:
function js(){
$(“img”).attr({ src: “test.jpg”, alt: “Test Image” });
}运行结果相当于<img src=”test.jpg” alt=”Test Image”/>
attr (key,value) 为第一个匹配对象的设置属性,key为属性名,value为属性值
<img/><a href=”#” onclick=”js()”>jQuery</a>jQuery代码及功能
function js(){
$(“img”).attr(“src”,”test.jpg”);










