Html:
<! DOCTYPE >
<Html>
<Head>
<Metahttp-equiv="Content-type"Content="Text/html; Charset=utf-8 ">
<Title>Untitled Document </Title>
<StyleType="Text/css" >
* {
Margin10px
Padding0;
Font-family:"Microsoft Ya Black","Arial","Sans-serif";
}
</Style>
<ScriptType="Text/javascript"Src="Js/jquery-2.2.2.min.js" >
</Script>
<ScriptType="Text/javascript" >
$(function () {
$("#btn1").Clickfunction () {
VarTextstr= $("#test").Text ();
$("#txt1").TextTEXTSTR);
});
$("#btn2").Clickfunction () {
VarTextstr= $("#test"). html ();
$("#txt2"). HTML (TEXTSTR);
});
})
</Script>
</Head>
<Body>
<PId="Test" >
There are 3 ways to get <Strong>HTML element </Strong>The contents, respectively, are:<br/>
<Strong>Text (): Sets or returns the text content of the selected element </strong><br/>
<Strong>HTML (): Sets or returns the contents of the selected element (including HTML tags) </strong><br/>
<Strong>Val (): Sets or returns the value of a form field </strong><br/>
</P>
<TextAreaId="Txt1"Name="TextValue"cols="80"Rows="8" ></Textarea>
<buttonId="BTN1" >Display text </Button>
<TextAreaId="Txt2"name= "TextValue" cols= "rows= "8" ></TEXTAREA>
<div>
<id=< Span style= "color: #e6db74; Font-weight:bold; " > "btn2" > show Html</button
</DIV>
</body>
</HTML>
Result
2
Get HTML element content