【发布时间】:2016-01-21 01:36:45
【问题描述】:
我不太明白区别,在依赖关系树中只有一个my_class类的情况下,在:
$(this).parent().closest('.my_class').attr('id');
和
$(this).parents('.my_class').attr('id')
真的有区别吗?
编辑:没有这个没有重复,因为这里我以依赖树中只有一个 my_class 为例。我知道当 parents() 返回匹配元素的列表时 parent() 只返回一个元素,并且如果它与过滤器匹配,则最接近的 () 可以返回“this”。
HTML 示例:
<div class="agenda_relative">
<div class="agenda_day" data-date="<?php echo $year."-".$m."-".$d; ?>">
<div class="agenda_day_nr"><?php echo $d; ?></div>
<ul class="agenda_hour">
<?php foreach ($date->hours as $h): ?>
<li><?php echo $h; ?><p class='agenda_hour_input' data-hour="<?php echo $h; ?>" contenteditable="true"></p>
关于我想获取议程日期 div 的数据(“日期”)上的事件模糊
我有可行的解决方案,但我想知道上述两种方法之间是否有任何区别
【问题讨论】:
-
HTML 是什么样的?
-
请查看编辑,我的问题与您找到的问题略有不同,这就是我问它的原因
标签: jquery