Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c0f6f32

Browse files
input event in js
1 parent 3a1c0a1 commit c0f6f32

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

‎Basic Introduction/index.html

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,29 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Document</title>
8-
9-
<style>
10-
11-
body{
12-
height: 300vh;
13-
}
14-
</style>
158
</head>
169
<body>
1710

11+
<form action="">
12+
13+
Name <input type="text" id="myInput">
14+
</form>
15+
16+
1817
<script>
1918

20-
window.addEventListener('scroll' , function(){
21-
22-
if(window.pageYOffset > 200)
23-
{
24-
document.body.style.backgroundColor = 'red';
25-
}
26-
else
27-
{
28-
document.body.style.backgroundColor = 'white';
29-
}
30-
})
19+
let x = document.getElementById('myInput');
20+
21+
x.addEventListener('focus' , myFocusFunction);
22+
x.addEventListener('blur' , myBlurFuction);
23+
24+
function myFocusFunction(){
25+
x.style.background = 'yellow';
26+
}
27+
28+
function myBlurFuction(){
29+
x.style.background = 'white';
30+
}
3131
</script>
32-
3332
</body>
3433
</html>

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /