Wal*_*ker 23 jquery jquery-selectors
我正在尝试为兄弟的孩子提供一个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>
Run Code Online (Sandbox Code Playgroud)
JS:
$(".talking-point.section1").mouseenter(function() {
$(this).siblings(".screenshots").children("tab").hide();
$(".screenshots .tab1").show();
$(this).siblings(".screenshots").css("background-position","0 0");
});
Run Code Online (Sandbox Code Playgroud)
jAn*_*ndy 17
逻辑上它应该工作.你缺少点.的.children()jQuery选择.
.children(".tab")
Run Code Online (Sandbox Code Playgroud)
使用find而不是children为我工作:
$(this).siblings(".screenshots").find("tab")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29827 次 |
| 最近记录: |