JQuery's method of getting label text content and html content
This article mainly introduces jQuery's method of obtaining the label text content and html content. It analyzes the usage skills of the text and html methods in jQuery by examples and has some reference value, for more information, see
This document describes how jQuery obtains the tag text content and html content. Share it with you for your reference. The specific analysis is as follows:
JQuery can use the text and html methods to obtain the text content or html content of a specified tag.
?
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" example .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> |
I hope this article will help you with jQuery programming.