HTMLDOMTextareaプレースホルダープロパティ
HTML DOM Textareaプレースホルダープロパティは、HTMLドキュメントのテキストエリア要素のプレースホルダー属性の値を返し、変更します。
構文
以下は構文です-
1。プレースホルダーを返す
object.placeholder
2。プレースホルダーの追加
object.placeholder = “text”
HTML DOM Textareaプレースホルダープロパティの例を見てみましょう:
例
<!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;
}
.show {
margin: 1rem 0;
font-size: 1.5rem;
}
</style>
<body>
<h1>DOM Textarea placeholder Property Demo</h1>
<textarea placeholder="Hi! I'm placeholder text of a textarea element" rows="8" cols='20'></textarea>
<button onclick="set()" class="btn">Show Placeholder</button>
<div class="show"></div>
<script>
function set() {
document.querySelector('.show').innerHTML = document.querySelector("textarea").placeholder;
}
</script>
</body>
</html> 出力
「プレースホルダーを表示」をクリックします 」ボタンをクリックして、プレースホルダー属性の値を表示します。
-
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</