我有带微笑的 div 和 contenteditable div:
<div id="smiles">
<img src="/img/smile/acute.gif">
<img src="/img/smile/aggressive.gif">
<img src="/img/smile/bad.gif">
<img src="/img/smile/biggrin.gif">
<img src="/img/smile/blum1.gif">
<img src="/img/smile/blush.gif">
<img src="/img/smile/boredom.gif">
<img src="/img/smile/bye.gif">
<img src="/img/smile/clapping.gif">
<img src="/img/smile/congratulate.gif">
<img src="/img/smile/cool.gif">
<img src="/img/smile/cray.gif">
<img src="/img/smile/dance.gif">
<img src="/img/smile/dance2.gif">
</div>
<div contenteditable="false" unselectable="true" style="disabled:true" id="message_text"></div>
和 jQuery 代码:
$("#smiles").on('click', 'img', function () {
if ($('#message_text').prop("contentEditable") == 'true') {
$('#message_text').append($(this).clone()).focus();
}
});
附加光标后在附加微笑之前保持不变,但我需要在之后设置它