1、選擇第一級子節點
通過> 或者children方法實作
$('#XtraTabPage8>.datagrid-ftable')
$('#XtraTabPage8').children('.datagrid-ftable')
2、選擇所有的子節點,即后代節點
通過空格實作
$('#XtraTabPage8 .datagrid-ftable')
用find函式
$('#XtraTabPage8').find('.datagrid-ftable')
3、選擇同級
$('#XSmartDictLookup8').prev()
$('#XSmartDictLookup8').next()
4、選擇父級
$('#XSmartDictLookup8').parent()
$('#XSmartDictLookup8').parents('#InputPanel') ---帶篩選的選擇父級,可以查找所有父級元素
5、模糊匹配
$("div[class^='hint']"); ---class前綴為hint的所有div的jquery物件
$("div[class$='hint']"); ---class后綴為hint的所有div的jquery物件
$("div[class*='hint']"); ---class中包含hint的所有div的jquery物件
[屬性名稱] 匹配包含給定屬性的元素
[att=value] 匹配包含給定屬性的元素 (大小寫區分)
[att*=value] 模糊匹配包含有value的原色
[att!=value] 不能是這個值
[att^=value] 以value開頭的所有元素
[att$=value] 以value結尾的所有元素
[att1][att2][att3]… 匹配多個屬性條件中的一個
class有多個時的模糊匹配,
例:<div style="white-space: normal; height: auto; width: 96px;" >
模糊匹配JS為 $("div[class$='MXVALUE datagrid-editable']"); ---把class當做一個字串看待
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/39146.html
標籤:jQuery
