1. 程式人生 > 其它 >用一個div盒子去模擬textarea的實現

用一個div盒子去模擬textarea的實現

在這裡插入圖片描述
操作contenteditable屬性,值為Boolean值true繫結元素可編輯false(預設)元素不可編輯。

<div id="textarea" contenteditable="true">
<style>
#textarea{
    width:300px;
    border:1px solid #ccc;
    min-height:150px;
    max-height:300px;
    overflow:auto;
    font-size:14px;
    outline:none;
}
</style>

在這裡插入圖片描述