-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path8_jQuery.html
More file actions
48 lines (43 loc) · 1.24 KB
/
8_jQuery.html
File metadata and controls
48 lines (43 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Q.8 jQuery Event Handling</title>
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
</head>
<body>
<button id="myButton">Click me!</button>
<p id="myParagraph">Mouse over me!</p>
<input type="text" id="myInput" placeholder="Type something" />
<form id="myForm">
<input type="submit" value="Submit Form" />
</form>
<img
id="myImage"
src="https://via.placeholder.com/200"
alt="Sample Image"
/>
<script>
// On Click Event
$('#myButton').on('click', function () {
alert('Button clicked!');
});
// On Mouse out Event
$('#myParagraph').on('mouseout', function () {
$(this).css('background-color', 'red');
});
// On Key Up Event
$('#myInput').on('keyup', function () {
var inputValue = $(this).val();
alert('Input value:', inputValue);
});
// On Form Submit Event
$('#myForm').on('submit', function (event) {
event.preventDefault();
alert('Form submitted!');
});
</script>
</body>
</html>