<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) –