我正在自定义基于聊天的Web界面。我对正在使用的标记的控制非常有限。
基本上,我想在每条聊天消息中添加新元素<span class="icon" />
。
<div id="chatLog">
<span class="msg agent">
<strong>Agent Name</strong>
Hi, how are you today? How can I help?
</span>
<span class="msg customer">
<strong>Customer Name</strong>
I'm fine thanks, please can you tell me more about the products you sell?
</span>
</div>
我想使用的jquery是这样的:
<script>
jquery('.msg').append('<span class="icon" />');
</script>
所以我有
<div id="chatLog">
<span class="msg agent">
<strong>Agent Name</strong>
Hi, how are you today? How can I help?
<span class="icon" />
</span>
<span class="msg customer">
<strong>Customer Name</strong>
I'm fine thanks, please can you tell me more about the products you sell?
<span class="icon" />
</span>
<div id="chatLog">
随着代理和客户之间发送越来越多的消息,标记将不断变化。如何确保所有聊天消息span.msg
都附加了此新元素<span class="icon" />
?
<div id="chatLog">
<span class="msg agent"><strong>Agent Name</strong>Hi, how are you today? How can I help?</span>
<span class="msg customer"><strong>Customer Name</strong>I'm fine thanks, please can you tell me more about the products you sell?</span>
<span class="msg agent"><strong>Agent Name</strong>Yes certainly, any particular product?</span>
<span class="msg customer"><strong>Customer Name</strong>Product ISBN-123-456 please</span>
<div id="chatLog">