-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathset.html
53 lines (39 loc) · 1.51 KB
/
set.html
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
49
50
51
52
53
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function () {
$("#btn1").click(function () {
$("#test1").text(function (i, originalText) {
return `Old text: ${originalText} New text: Hello World! (index: ${i})`;
});
});
$("#btn2").click(function () {
$("#test2").html(function (i, originalText) {
return `Old html: ${originalText} New html: Hello <b> World! </b> (index: ${i})`
});
});
$("#btn3").click(function () {
$("#test3").val("Hello World!");
});
$("#btn4").click(function () {
$("#hreftag").attr({
"href": "https://github.com/"
});
$("#linktag").children("a").text("github.com");
});
});
</script>
</head>
<body>
<p id="test1">This is a <b>bold</b> paragraph.</p>
<p id="test2">This is another <b>bold</b> paragraph.</p>
<p>Input field: <input type="text" id="test3" value="Mickey Mouse"></p>
<p id="linktag"><a id="hreftag" href="https://www.google.com/" target="blank">google.com</a></p>
<button id="btn1">Show Old/New Text</button>
<button id="btn2">Show Old/New HTML</button>
<button id="btn3">Set Value</button>
<button id="btn4">Change href and title</button>
</body>
</html>