is
英 [?z]? ?美 [?z]??
vt.& vi.是(be的三單形式)
n.存在
jquery is()方法 語法
作用:is() 根據(jù)選擇器、元素或 jQuery 對象來檢測匹配元素集合,如果這些元素中至少有一個元素匹配給定的參數(shù),則返回 true。
語法:.is(selector)
參數(shù):
參數(shù) | 描述 |
selector? ?? | 字符串值,包含匹配元素的選擇器表達(dá)式。 |
說明:與其他篩選方法不同,.is() 不創(chuàng)建新的 jQuery 對象。相反,它允許我們在不修改 jQuery 對象內(nèi)容的情況下對其進(jìn)行檢測。這在 callback 內(nèi)部通常比較有用,比如事件處理程序。
jquery is()方法 示例
<!DOCTYPE html> <html> <head> <style>div { color:red; }</style> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> </head> <body> <form><p><input type="checkbox" /></p></form> <div></div> <script> var isFormParent = $("input[type='checkbox']").parent().is("form"); $("div").text("isFormParent = " + isFormParent); </script> </body> </html>
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例