Home > Web Front-end > JS Tutorial > body text

Example of using text method to obtain text information of Html elements_javascript skills

WBOY
Release: 2016-05-16 16:38:17
Original
1489 people have browsed it

There are many ways to obtain text information. This example uses the text method of jquery. I believe everyone has used this method. It is simple and practical. After obtaining it, use alert to pop up the text. The following is the implementation code

<!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>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template