【发布时间】:2013-05-21 10:18:54
【问题描述】:
我正在处理一个动态创建的元素列表,其中一些元素与一个类或“Set1、Set2”等相关联。这些元素有多个类,按照不同的分配顺序,但每个元素只有一个类开始用'Set...',比如...
<div class="SharedClass anotherClass Set2 yetAnotherClass">SomethingA</div>
<div class="SharedClass anotherClass Set2 yetAnotherClass">SomethingB</div>
<div class="someClass SharedClass Set3 yetAnotherClass">SomethingC</div>
那么,如何将以“Set”开头的特定类从变量“clickedSet”中提取出来,以便为该点击函数提供种子,从而仅显示当前点击集的成员?
$('.SharedClass').click(function(){
var clickedSet = $(this). //Get the specific classname starting with 'Set...'
$(':not("clickedSet")').hide();
$('.clickedSet').show();
});
感谢您的任何想法。 最好的, 基思..
【问题讨论】:
标签: jquery class variables jquery-selectors startswith