<li class="person" data-chat="person1">
<img src="http://s13.postimg.org/ih41k9tqr/img1.jpg" alt="" />
<span class="name">user time</span>
<span class="time">0:00 AM</span>
<span class="preview">last message</span>
</li>
我有一個VAR時間的實際時間。我想將值0:00 AM替換爲具有屬性data-chat="person1"
的var時間。如何通過查找屬性來更新html?
正如古老的問題...什麼企圖,如果有的話,你有沒有解決這個問題提出?如果你只是尋找具有該屬性的元素,你可以執行'$(「[data-chat ='person1']」)'。 – Santi
[改變具有特定數據屬性的所有元素的文本]的可能重複(http://stackoverflow.com/questions/23258618/change-text-of-all-elements-with-specific-data-attribute) –