CodeLab
Show Output
 
xxxxxxxxxx
18
 
1
<!DOCTYPE html>
2
<html lang="en">
3
<head>
4
<meta charset="utf-8">
5
<title>jQuery Set HTML Contents of the Element</title>
6
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
7
<script>
8
$(document).ready(function(){
9
    $("button").click(function(){
10
        $("body").html("<p>Hello World!</p>");
11
    });
12
});
13
</script>
14
</head>
15
<body>
16
    <button type="button">Write Message</button>
17
</body>
18
</html>
 

在微博、微信、公众号、小程序分享此示例。 如果您觉得有帮助,请给我们一个赞。