AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > JavaScript

jQuery获取标签文本内容和html内容的方法

51自学网 http://www.wanshiok.com
jQuery,获取,标签,文本内容,html内容,方法

本文实例讲述了jQuery获取标签文本内容和html内容的方法。分享给大家供大家参考。具体分析如下:

jQuery可以通过text和html方法获取指定标签的文本内容或者html内容

<!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程序设计有所帮助。


jQuery,获取,标签,文本内容,html内容,方法  
上一篇:jquery使用animate方法实现控制元素移动  下一篇:Node.js 去掉种子(torrent)文件里的邪恶信息