如何使用jQuery替换div的innerHTML?

How to replace innerHTML of a div using jQuery?

您可以尝试运行以下代码,以了解如何替换div的innerHTML:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">

$(document).ready(function(){
  $("#button1").click(function(){
   $('#demo').html('Demo text');
 });
});

</head>
<body>

This is Amit!

<button id="button1">Replace</button>
</body>
</html>