這是類名爲「assistance_wrap」的樣本格。更改ID中的班級
<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與類樣品div的副本「assistance_wrap」 並分配唯一的ID,並顯示我的網頁上。 現在我想改變類裏面的文字near_header亮點誰的父母div id是 assistance_wrap_316我應該怎麼做?
這是我試過的。日誌的輸出基本上是div的整個文本,編號爲assistance_wrap_316。
console.log(new_info.find('#assistance_wrap_'+ event_data.eventId , '.nearby_header highlight').text());
假設event_data.eventId的價值爲316
如果'new_info'是副本帶有'assistance_wrap'類的div然後做'new_info.find('#assistance_wrap _...'試圖fin d內部的div – MrOBrian 2012-07-17 22:47:12