使用text方法获取Html元素文本信息示例
获取文本信息的方法有很多,本例使用的使用的是jquery的text方法,这个方法想必大家都有使用过吧,简单实用。获取之后并使用alert将文本弹出,下面是实现代码
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
p { margin:8px; font-size:20px; color:blue;
cursor:pointer; }
b { text-decoration:underline; }
button { cursor:pointer; }
</style>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
</head>
<body>
<b>Show My Text</b>
<div id="TEXT"></div>
<script>
$("#TEXT").load("qqq.txt", function(response, status, xhr) {
var text=$(this).text();
alert( text);
});
</script>
</body>
</html> 相关推荐
lupeng 2020-11-14
sjcheck 2020-11-10
meylovezn 2020-08-28
owhile 2020-08-18
Francismingren 2020-08-17
pythonclass 2020-07-29
sunzhihaofuture 2020-07-19
爱读书的旅行者 2020-07-07
行吟阁 2020-07-05
tianqi 2020-07-05
行吟阁 2020-07-04
冰蝶 2020-07-04
lyg0 2020-07-04
owhile 2020-07-04
opspider 2020-06-28
lengyu0 2020-06-28
tianqi 2020-06-21
dadaooxx 2020-06-16