这是类名为“ assistance_wrap ”的示例 div。
<div class="assistance_wrap">
<div class="top"></div>
<div class="header highlight">Types of assistance offered at this event:</div>
<div class="nearby_header highlight">This event is currently full, but there are other ways you can</div>
</div>
我已经克隆了这个 div,每个克隆的版本都有一个唯一的 ID。
<div id="assistance_wrap_315" class="assistance_wrap">
<div class="top"></div>
<div class="header highlight">Types of assistance offered at this event:</div>
<div class="nearby_header highlight">This event is currently full, but there are other ways you can</div>
<div id="assistance_wrap_316" class="assistance_wrap">
<div class="top"></div>
<div class="header highlight">Types of assistance offered at this event:</div>
<div class="nearby_header highlight">This event is currently full, but there are other ways you can</div>
在我的 JS 中,我将名称new_info分配给具有类“assistance_wrap”的示例 div 的副本,并为其分配唯一的 Id 并显示在我的页面上。现在我想更改类near_header 中的文本突出显示谁的父 div id 是 assistance_wrap_316我应该怎么做?
这是我尝试过的。日志的输出基本上是 id 为assistant_wrap_316的 div 的整个文本。
console.log(new_info.find('#assistance_wrap_'+ event_data.eventId , '.nearby_header highlight').text());
假设 event_data.eventId 的值为 316