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;
background: lightseagreen;
height: 100vh;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
}
</style>
<body>
<h1>DOM Textarea cols Property Demo</h1>
<textarea>Hi! I'm a textarea element in an HTML document with some dummy text.</textarea>
<button onclick="set()" class="btn">Set Cols = 50</button>
<script>
function set() {
document.querySelector("textarea").cols = '50';
}
</script>
</body>
</html> 出力
「SetCols=50」をクリックします ”ボタンをクリックしてcols属性の値を50に設定します。
-
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 {
-
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</