目前知道的四个获取文字的方法:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="jquery-3.4.1.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>小白网页</title>
</head>
<body>
<a id="introduce">我是小白</a>
</body>
<script type="text/javascript">
// 修改其中的文字
$("#introduce").text("变成了小黑");
$("#introduce")[0].innerText = "变成了小黑1";
$("#introduce").html("变成了小黑2");
$("#introduce")[0].innerHTML = "变成了小黑3"
// 修改 href 属性
$("#introduce").attr("href","index.jsp");
</script>
</html>
要跳转出这个项目,a 标签中需设置 href 属性:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="jquery-3.4.1.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>小白网页</title>
</head>
<body>
<a id="introduce" href="https://www.baidu.com">我是小白</a>
</body>
<script type="text/javascript">
// 修改其中的文字
$("#introduce").text("变成了小黑");
// 修改属性
$("#introduce").attr("href","https://blog.csdn.net/Alone_in_/article/details/103137818");
</script>
</html>
没啥好写的,就到这吧!