要素のスクロールバーがHTMLでスクロールされているときにスクリプトを実行しますか?
要素がスクロールされると、 onscroll 属性トリガー。次のコードを実行して、 onscrollを実装してみてください。 属性-
<!DOCTYPE html>
<html>
<head>
<style>
#myid {
width : 250px;
height : 80px;
border : 2px solid blue;
overflow: scroll;
}
</style>
</head>
<body>
<p>Scroll the box.</p>
<div id = "myid" onscroll = "display()">This is demo text. This is demo text. This is demo text. This is demo text. This is demo text. This is demo text.
<br><br></div>
<script>
function display() {
document.getElementById("myid").style.color = "blue";
}
</script>
</body>
</html> -
要素がHTMLでクリックされているときにスクリプトを実行しますか?
onclickを使用します 要素がHTMLでクリックされたときにスクリプトを実行する属性。 例 次のコードを実行して、 onclickを実装してみてください。 属性- <!DOCTYPE html> <html> <body> <button onclick = "display()">Click</button> <p id = "test"></p> &n
-
要素がHTMLでフォーカスを取得したときにスクリプトを実行しますか?
onfocusを使用する 要素がHTMLでフォーカスを取得したときにスクリプトを実行する属性。 例 次のコードを実行して、 onfocusを実装してみてください。 属性- <!DOCTYPE html> <html> <body> <p>Enter subject name below,</p> Subject: <input type = "text" id = "sname"