HTMLoninputイベント属性
HTML oninputイベント属性は、ユーザーがHTMLドキュメントのinput /textareaHTML要素に入力を入力したときにトリガーされます。
構文
以下は構文です-
<tagname oninput=”script”></tagname>
例
入力イベント属性のHTMLの例を見てみましょう-
<!DOCTYPE html>
<html>
<head>
<style>
body {
color: #000;
height: 100vh;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;
text-align: center;
padding: 20px;
}
textarea {
border: 2px solid #fff;
background: transparent;
font-size: 1rem;
}
::placeholder {
color: #000;
font-size: 1rem;
}
</style>
</head>
<body>
<h1>HTML oninput Event Attribute Demo</h1>
<textarea placeholder="Enter your message here" oninput="inputFn()" rows='8' cols="50"></textarea>
<script>
function inputFn() {
document.querySelector('textarea').style.background = '#ffffff36';
}
</script>
</body>
</html> 出力
次に、テキスト領域にメッセージを入力して、oninputイベント属性がどのように機能するかを確認します。
-
HTMLondragendイベント属性
HTML ondragendイベント属性は、ユーザーがHTMLドキュメント内のHTML要素の要素またはテキストのドラッグを終了したときにトリガーされます。 構文 以下は構文です- <tagname ondragend=”script”></tagname> HTMLオンドラッグイベント属性の例を見てみましょう- 例 <!DOCTYPE html> <html> <head> <style> body { color: #000;
-
HTMLonpageshowイベント属性
HTML onpageshowイベント属性は、ユーザーがWebページに移動したときにトリガーされます。 構文 以下は構文です- <body onpageshow=”script”></body> HTMLonpageshowイベント属性の例を見てみましょう- 例 <!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; &nb