-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_js_click.html
More file actions
44 lines (37 loc) · 860 Bytes
/
test_js_click.html
File metadata and controls
44 lines (37 loc) · 860 Bytes
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>trigger demo</title>
<style>
button {
margin: 10px;
}
div {
color: blue;
font-weight: bold;
}
span {
color: red;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<button id="button1">Button #1</button>
<button>Button #2</button>
<div><span>0</span> button #1 clicks.</div>
<div><span>0</span> button #2 clicks.</div>
<script>
$( "#button1" ).on( "click", function() {
console.log( $( this ).text() );
});
$( "#button1" ).trigger( "click" );
$( "#button1" ).trigger( "click" );
function update( j ) {
var n = parseInt( j.text(), 10 );
j.text( n + 1 );
}
</script>
</body>
</html>