在此示例中,我想在光标到达或触摸发送按钮时添加边距,并在触摸时添加边距顶部所需的发送按钮。与当前的Facebook评论字段一样,当光标触摸贴纸或表情符号图标时,图标将移动到字段的底部。
autosize($('textarea'));

textarea { width:99%;min-height:15px }
div { position:relative }
button { position:absolute;right:10px;bottom:8px }

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/jackmoore/autosize/master/dist/autosize.min.js"></script>
<div>
<textarea class="textarea"></textarea>
<button>
Send
</button>
</div>
&#13;
答案 0 :(得分:0)
以下是您要找的内容,请尝试一下:
autosize($('textarea'));
$("#send").on('click', function() {
console.log("You clicked send!!");
callSendFunction();
});
$('.textarea').keypress(function(e) {
if (e.which == 13) {
console.log("You hit enter!!");
callSendFunction();
}
});
function callSendFunction() {
console.log('Yay, we got it. Do something here.. ');
}
textarea {
width: 99%;
min-height: 15px
}
div {
position: relative
}
button {
position: absolute;
right: 10px;
bottom: 8px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://rawgit.com/jackmoore/autosize/master/dist/autosize.min.js"></script>
<div>
<textarea class="textarea"></textarea>
<button id="send">
Send
</button>
</div>
答案 1 :(得分:0)
将文字区域硬包装到最大
<textarea NAME="myTextArea" ROWS="5" WRAP="HARD"></textarea>
<script>
var numCols = document.getElementById('myTextArea').cols;
document.getElementById('myTextArea').cols=numCols-7;
</script>