HTML DOMTextareaautofocusプロパティ
HTML DOM Textarea autofocusプロパティは、ページの読み込み時にテキスト領域が自動的にフォーカスされるかどうかを返し、変更します。
構文
以下は構文です-
1。オートフォーカスを返す
object.autofocus
2。オートフォーカスの変更
object.autofocus = true | false
HTML DOM Textarea autofocusプロパティの例を見てみましょう:
例
<!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;
}
</style>
<body>
<h1>DOM Textarea autofocus Property Demo</h1>
<textarea autofocus>Hi! I'm a text area element with some dummy text.</textarea>
<button onclick="set()" class="btn">Disable Autofocus</button>
<script>
function set() {
document.querySelector("textarea").autofocus = false;
}
</script>
</body>
</html> 出力
「オートフォーカスを無効にする」をクリックします 」ボタンをクリックして、textarea要素のオートフォーカスを無効にします。これで、カーソルは表示されなくなります:
-
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</