如何使用 jQuery 更改元素內的文字?
若要使用 jQuery 更改元素內部文字,請使用 text() 方法。
示例
您可嘗試執行以下程式碼以替換元素內的文字
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#demo').text('The replaced text.');
});
</script>
</head>
<body>
<div id="demo">
<p>The initial text</p>
</div>
</body>
</html>
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP