- JQuer选择器:
#id
$("#idName");
.class:
$(".className");
element:
$(“div”);
:匹配所有元素
$("");
selector1,selector2,selectorN:
$(“div,span,p.className”);
ancestor descendant:
$(“form input”);
parent > child:
$(“form > input”)
prev + next:
$(“label + input”)
prev ~ siblings:
$(“form ~ input”);
:first:
$(‘li:first’);
:not(selector):
$(“input:not(:checked)”);
:even:
$(“tr:even”);
:odd:数
$(“tr:odd”);
:eq(index) :
$(“tr:eq(1)”);
:gt(index):
$(“tr:gt(0)”);
:lang(language):
$(“p:lang(it)”)
:last() :
$(‘li:last’);
:lt(index):
$(“tr:lt(2)”)
:header :
$(":header").css(“background”, “#EEE”);
:animated:
$("#run").click(function(){
$(“div:not(:animated)”).animate({ left: “+=20” }, 1000);
});
:focus :
$( “#content” ).delegate( “*”, “focus blur”, function( event ) {
var elem = $( this );
setTimeout(function() {
elem.toggleClass( “focused”, elem.is( “:focus” ) );
}, 0);
});
:root:
$(":root").css(“background-color”,“yellow”);
:contains(text):
$(“div:contains(‘John’)”)
:empty:
$(“td:empty”)
:has(selector):
$(“div:has§”).addClass(“test”);
:parent:
$(“td:parent”);
:hidden :
$(“tr:hidden”);
:visible :
$(“tr:visible”)
[attribute] :
$(“div[id]”)
[attribute=value] :
$(“input[name=‘newsletter’]”).attr(“checked”, true);
:first-child :
$(“ul li:first-child”)
:last-child:
$(“ul li:last-child”)
:only-child :
$(“ul li:only-child”)
:input:
$(":input")
:text:
$(":text")
:password:
:image:
$(":image")
:checked :
:selected :