<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<style>
div{
width: 500px;
moz-user-select:none; /* Firefox私有属性 */
-webkit-user-select:none; /* WebKit内核私有属性 */
-ms-user-select:none; /* IE私有属性(IE10及以后) */
-khtml-user-select:none; /* KHTML内核私有属性 */
-o-user-select:none; /* Opera私有属性 */
user-select:none; /* CSS3属性 */
}
p{
width: 500px;
height: 200px;
border: 1px solid #eee;
overflow: hidden;
overflow-y: auto;
padding: 10px;
-webkit-user-modify: read-write;
}
p:focus {
outline:none;
border: 1px solid pink;
}
button {
border:none;
background:purple;
color: #FFf;
border-radius: 5px;
outline:none;
width: 80px;
height: 40px;
position: absolute;
top:400px;
left: 400px;
}
</style>
<body>
<div></div>
<p contenteditable="true" oninput="num(this)"></p>
<button>发送</button>
</body>
<script>
var html=""
for (var i=0;i<135;i++) {
html+=`<img src="./${i<10?0:""}${i}.gif" data-path="./${i<10?0:""}${i}.gif" onclick="add(this)"/>`
}
document.querySelector("div").innerHTML=html
function add(a) {
var path = a.dataset.path
var str=`<img src="${path}" />`
document.querySelector("p").innerHTML+=str
}
function num(str) {
console.dir(str.innerHTML.length)
}
</script>
</html>