我試圖讓一個兄弟姐妹的孩子jQuery選擇(在頁面上的多個部分,從而需要剛好到達兄弟姐妹的孩子(而thna能夠使用一般選擇器)jQuery選擇器的兄弟姐妹的孩子?
HTML:
<div class="tour-section">
<div class="screenshots left">
<div class="tab tab1"></div>
<div class="tab tab2"></div>
<div class="tab tab3"></div>
<div class="tab tab4"></div>
</div>
<div class="talking-point section1">
<h2 class="primary-color-text">Create your listing</h2>
<p class="subheader">Create your job listing by adding a few simple details</p>
</div>
</div>
JS:?
$(".talking-point.section1").mouseenter(function() {
$(this).siblings(".screenshots").children("tab").hide();
$(".screenshots .tab1").show();
$(this).siblings(".screenshots").css("background-position","0 0");
});
你真的不應該把一個'class'上* *的一切。這樣做可能是沒有正確使用選擇器的一個標誌。 – 2010-08-25 07:18:36
如果.talking-point.section1在.screenshots之前,你甚至可以通過這個CSS選擇器獲得.tab:'''.talking-point.section1 + .screenshots .tab''' – esp 2013-01-25 19:58:14