<html>
<head>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.4.1.min.js"></script>
</head>
<body>
<h1>获取文本内容</h1>
<h2 id="01">Hello World!</h2>
<h2 id="02">Hello Sweden!</h2>
<h2 id="03">Hello Japan!</h2>
<p id="demo"></p>
<script>
$(document).ready(function() {
var myElement = $("#02");
var myText = myElement.text();
$("#demo").text(myText);
});
</script>
</body>
</html>