我有带微笑的 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">
<img src="/img/smile/boredom.gif">
</div>
和 jQuery 代码:
$("#smiles").on('click', 'img', function () {
if ($('#message_text').prop("contentEditable")) {
$('#message_text').append($(this).clone()).focus();
}
});
我也在尝试
if ($('#message_text').attr("contentEditable"))
如果 div 是 contentEditable 但IF
不起作用,我想追加微笑