JSFiddle - React, Tailwind, and code Playground
by Karan1412
HTML
<html>
<head>
<title>text</title>
</head>
<body>
<p id="targetP">This is 99codingexamples. <span>This is span element.</span></p>
<b>List of Players :</b>
<ul id="targetUL">
<li>Cesc Fabregas</li>
<li>Thierry Henry</li>
<li>Ronaldinho</li>
<li>Tomas Rocisky</li>
<li>Robin Van Persie</li>
</ul>
<input type="button" id="textP" value="text() for P" />
<input type="button" id="textUL" value="text() for UL" />
</body>
</html>
JavaScript
$(document).ready(function () {
$("#textP").click(function () {
var textP = $("#targetP").text();
alert(textP);
});
$("#textUL").click(function () {
var textUL = $("#targetUL").text();
alert(textUL);
});
});