获取更新元素文本text()

text() 方法,获取元素文本,也可以设置元素的文本值。相

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>获取更新元素文本</title>
    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-3.3.1.min.js"></script>
</head>
<body>
<p>Hello kity</p>
<script>
    alert($("p").text());
    $('p').text("麦克斯的博客")
</script>
</body>
</html>

  

当于JavaScript中的textContent。

猜你喜欢

转载自www.cnblogs.com/max-hou/p/9126123.html