JSFiddle - React, Tailwind, and code Playground

by deepak sisodiya

HTML

<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>

JavaScript

/* Get Content - text(), html(), and val()
text() - Sets or returns the text content of selected elements
html() - Sets or returns the content of selected elements (including HTML markup)
val() - Sets or returns the value of form fields
*/

$("#btn1").click(function () {
    alert("Text: " + $("#test").text());
});
$("#btn2").click(function () {
    alert("HTML: " + $("#test").html());
});