情况如下。我有一张聊天桌
<table id="shoutbox_table" cellspacing="0" cellpadding="2" border="0">
<tr id="shoutbox_msgs"><td></td></tr>
</table>
以及发布消息的字段
<input type="text" id="shoutbox_message" style="text-decoration:underline;padding:2px 0;width:90%" onkeypress="var k = window.event ? event.keyCode : event.which; if (k == 13) Shoutbox_SentMsg('22d0963fed98aac17f50112871dd7e81');" />
通过XMLHttpRequest加载到表中的内容,聊天看起来像这样
<table id="shoutbox_table" cellspacing="0" cellpadding="2" border="0">
<tbody>
<tr id="shoutbox_row43"><td nowrap="nowrap" style="text-align:right" class="smalltext" valign="top"><a href="http://phoenix-warriors.ru/index.php?action=profile;u=270" target="_blank" style="color:#ff009c">Mrak07</a> <span style="color:#FFFFFF">[22 Фев 08:05]</span>:</td><td style="text-align:left" class="smalltext" valign="top"><span style="">4 день донатная рарка(</span></td></tr>
<tr id="shoutbox_row44"><td nowrap="nowrap" style="text-align:right" class="smalltext" valign="top"><a href="http://phoenix-warriors.ru/index.php?action=profile;u=270" target="_blank" style="color:#ff009c">Mrak07</a> <span style="color:#FFFFFF">[22 Фев 08:55]</span>:</td><td style="text-align:left" class="smalltext" valign="top"><span style=""><a href="http://berserktcg.ru/?gift=fb515520-1fb5-473f-8ff8-edb83a4855b2" target="_blank">http://berserktcg.ru/?gift=fb515520-1fb5-473f-8ff8-edb83a4855b2</a></span></td></tr>
<tr id="shoutbox_row45"><td nowrap="nowrap" style="text-align:right" class="smalltext" valign="top"><a href="http://phoenix-warriors.ru/index.php?action=profile;u=270" target="_blank" style="color:#ff009c">Mrak07</a> <span style="color:#FFFFFF">[22 Фев 09:12]</span>:</td><td style="text-align:left" class="smalltext" valign="top"><span style="">играю телохранами сливаюсь от всех подряд</span></td></tr>
<tr id="shoutbox_row46"><td nowrap="nowrap" style="text-align:right" class="smalltext" valign="top"><a href="http://phoenix-warriors.ru/index.php?action=profile;u=525" target="_blank" style="color:#00AC14;">Безуминка</a> <span style="color:#FFFFFF">[22 Фев 09:17]</span>:</td><td style="text-align:left" class="smalltext" valign="top"><span style="">привет всем</span></td></tr><tr id="shoutbox_msgs"></tr>
</tbody></table>
我需要 - 当点击这个Mrak07时 - 抓住锚并将其粘贴到
我写了这段代码
$('#shoutbox_table').on('click', 'a[target="_blank"]', function(event){
event.preventDefault();
var sayto=$(this).text();
$("#shoutbox_message").val("["+sayto+"], "+$("#shoutbox_message").val());
$("#shoutbox_message").focus();
});
它完全适用于静态内容 - https://jsfiddle.net/Reset5/j5qzt0uj/9/但不适用于论坛。请指点我解决这个问题。
P.S。论坛有jquery-1.10.1.min.js
P.S.2实际上甚至连警告都没有用这段代码解雇。