DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> JavaScript綜合知識 >> jQuery獲取標簽文本內容和html內容的方法
jQuery獲取標簽文本內容和html內容的方法
編輯:JavaScript綜合知識     

 這篇文章主要介紹了jQuery獲取標簽文本內容和html內容的方法,實例分析了jQuery中text和html方法的使用技巧,具有一定參考借鑒價值,需要的朋友可以參考下

   

本文實例講述了jQuery獲取標簽文本內容和html內容的方法。分享給大家供大家參考。具體分析如下:

jQuery可以通過text和html方法獲取指定標簽的文本內容或者html內容

? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <!DOCTYPE html> <html> <head> <script src="js/jquery.min.js"> </script> <script> $(document).ready(function(){ $("#btn1").click(function(){ alert("Text: " + $("#test").text()); }); $("#btn2").click(function(){ alert("HTML: " + $("#test").html()); }); }); </script> </head> <body> <p id="test">This is some <b>bold</b> text in a paragraph.</p> <button id="btn1">Show Text</button> <button id="btn2">Show HTML</button> </body> </html>

希望本文所述對大家的jQuery程序設計有所幫助。

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved