2017-07-05 1 views
0

この例では、カーソルが届くかまたは送信ボタンをタッチしたときに余白を追加したいときに、余白を追加するために必要な送信ボタンをタッチします。現在の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>

答えて

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>

+0

私の質問が更新されました。 – Hiptop

+0

さて、あなたは自分のコードから上の作業デモを持っています。あなたのニーズにそれを微調整することができます。あなたが助けを必要とするなら、私に知らせてください。第二に、回答があれば質問を変更すべきではありません。後でチェックするために来る人々は、文脈を取得しません。 –

0

ハード最大

<textarea NAME="myTextArea" ROWS="5" WRAP="HARD"></textarea> 
<script> 
var numCols = document.getElementById('myTextArea').cols; 
document.getElementById('myTextArea').cols=numCols-7; 
</script> 
012にテキストエリアをラップ
+0

私の質問が更新されました。 – Hiptop

関連する問題