嘿嘿,
我想解决不同段落的父元素。因为段落以不同的方式嵌套,我不能通过使用“最接近”或某事来以相同的方式解决问题。
这就是为什么我尝试使用正则表达式测试来解决#text-test
AND #img-test
:
<div class="text-test">
<p class"tester">texttest</p>
</div>
<div class="img-test">
<div class="wrapper">
<p class="tester">imgtest</p>
</div>
</div>
$('.tester').click(function() {
//$(this).closest('div').addClass('active');
/* get the closest div where the class ends up with -test
* and add class active
* wrapperdiv = $(this).closest('div').attr('class').test(/-test$/);
*/
//console.log(wrapperdiv)
});
您对我如何使用测试方法有什么建议吗?
干杯