使用text方法獲取Html元素文本信息示例
更新時間:2014年09月01日 09:03:03 投稿:whsnow
獲取文本信息的方法有很多,本例使用的使用的是jquery的text方法,并使用alert將文本彈出,下面是實現代碼
獲取文本信息的方法有很多,本例使用的使用的是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>
相關文章
js判斷當頁面無法回退時關閉網頁否則就history.go(-1)
當頁面沒有前驅歷史記錄時,點擊返回按鈕時直接關閉頁面,否則就退回到前一頁2014-08-08
jquery pagination插件動態(tài)分頁實例(Bootstrap分頁)
這篇文章主要為大家分享了Bootstrap靜態(tài)分頁和jquery pagination插件動態(tài)分頁兩個實例,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-12-12

