jquery html() text() val() difference

  1. <!DOCTYPE html>  
  2. <html>  
  3.     <head>  
  4.         <metacharset="UTF-8">   
  5.         <title></title>  
  6.             <scripttype="text/javascript"src="js/jquery-2.1.4.min.js"></script>     
  7.     </head>  
  8.     <body>  
  9.         <p><b>Hello</b> fine</p>  
  10.         <p>Thank you!</p>  
  11.     </body>  
  12.     <script>  
  13.         alert($("p").html());//Get the first html element under p  
  14.         alert($("p").text());//Get all the text values ​​of p  
  15.         alert($("p").val());// Must have value attribute to get it  
  16.           
  17.     </script>  
  18. </html>  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325784740&siteId=291194637