Today, when I was working on a comment function similar to that of QQ, I was at a loss and looked for answers everywhere on the Internet. Finally, I was inspired in a very small corner. I got to know a new thing, contenteditable.
The html code is as follows:
Copy the code code as follows:
<div id="guo" contenteditable="true">
<img src="qqface/1.gif" />
</div>
<input type="button" value="Insert" onclick="insert()" />
js code:
Copy the code code as follows:
function insert() {
$("#guo").append("<img src='qqface/2.gif' />");
}
Interface before operation:
The interface after clicking insert:
Enter text, and the inserted picture can also be copied from one input box to another.
knock off.