HTML DOMTextareamaxLengthプロパティ
HTML DOM Textarea maxLengthプロパティは、HTMLドキュメントのテキスト領域要素のmaxLength属性の値を返し、変更します。
構文
以下は構文です-
1。 maxLengthを返す
object.maxLength
2。 maxLengthの変更
object.maxLength = “number”
HTML DOM Textarea maxLengthプロパティの例を見てみましょう:
例
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
}
.show {
font-size: 1.5rem;
margin: 1rem 0;
}
</style>
<body>
<h1>DOM Textarea maxLength Property Demo</h1>
<textarea maxlength="50">Hi! I'm a text area element with some dummy text.</textarea>
<button onclick="set()" class="btn">Show Maximum Length</button>
<div class="show"></div>
<script>
function set() {
document.querySelector('.show').innerHTML = 'The maximum number of characters allowed in the above text area is ' + document.querySelector("textarea").maxLength;
}
</script>
</body>
</html> 出力
「最大長を表示」をクリックします 」ボタンをクリックして、textarea要素のmaxLength属性の値を表示します。
-
HTML DOMTextareacolsプロパティ
HTML DOM Textarea colsは、HTMLドキュメントのテキスト領域要素のcols属性の値を返し、変更します。 構文 以下は構文です- 1。 colsを返す object.cols 2。列の追加 object.cols = “number” HTML DOM Textarea colsプロパティの例を見てみましょう: 例 <!DOCTYPE html> <html> <style> body { color: #000; &nb
-
HTMLDOMTextarea必須プロパティ
HTML DOM Textarea requiredプロパティは、HTMLドキュメントのテキスト領域のrequired属性の値を返し、変更します。 構文 以下は構文です- 1。返却が必要です object.required 2。変更が必要です object.required = true | false HTML DOM Textarea requiredプロパティの例を見てみましょう: 例 <!DOCTYPE html> <html> <head> <title>DOM Textarea required Property</