Get text () and HTML ()
<! DOCTYPE html>
<script src= "/jquery/jquery-1.11.1.min.js" ></script>
<script>
$ (document). Ready (function () {
$ ("#btn1"). Click (function () {
alert ("Text:" + $ ("#test"). Text ());
});
$ ("#btn2"). Click (function () {
alert ("HTML:" + $ ("#test"). html ());
});
});
</script>
<body>
<p id= "Test" > This is the <b> bold </b> text in the paragraph. </p>
<button id= "BTN1" > Display text </button>
<button id= "BTN2" > Show html</button>
</body>
Get Val ()
<! DOCTYPE html>
<script src= "/jquery/jquery-1.11.1.min.js" ></script>
<script>
$ (document). Ready (function () {
$ ("button"). Click (function () {
Alert ("Value:" + $ ("#test"). Val ());
});
});
</script>
<body>
<p> Name: <input type= "text" id= "test" value= "Mickey Mouse" ></p>
<button> Display Values </button>
</body>
jquery Gets Content-text (), HTML (), and Val ()