使用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-08jquery pagination插件动态分页实例(Bootstrap分页)
这篇文章主要为大家分享了Bootstrap静态分页和jquery pagination插件动态分页两个实例,具有一定的参考价值,感兴趣的小伙伴们可以参考一下2016-12-12
最新评论