This is the sample div with class name “assistance_wrap“.
<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>
I have cloned this div and each cloned version has a unique ID attached to it.
<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>
In my JS I assign the name new_info to the copy of the sample div with class “assistance_wrap”
and assign unique Id to it and display on my page.
Now I want to change the text inside the class nearby_header highlight who’s parent div id is
assistance_wrap_316 how should I do this ?
This is what I have tried. The output of the log is basically the entire text of the div with id assistance_wrap_316.
console.log(new_info.find('#assistance_wrap_'+ event_data.eventId , '.nearby_header highlight').text());
Assume event_data.eventId’s value is 316
you should remove the
",":or use
find()method: