Elements text() - KirkGarcia182/domExtend GitHub Wiki
Sets or gets the textContent of the element
// sets the textContent of the element
element.text(text);
// gets the textContent of the element
element.text();
text - A String
that will represent the elements text content
The element you just manipulated or the text content of the element.
<!DOCTYPE html>
<html>
<head>
<title>domExt Examples</title>
</head>
<body>
<div id="app">
<div class="menus">
<ul id='menuList'>
<li><a class='menuLink'>Menu 1</a></li>
<li><a class='menuLink'>Menu 2</a></li>
<li><a class='menuLink'>Menu 3</a></li>
</ul>
</div>
</div>
<script type="text/javascript" src="domExt.js"></script>
<script type="text/javascript">
window.$ = document;
let app = $.byId('app');
app.text('Hello World!');
console.log(app);
/* Result
<div id='app'>
Hello World!
</div>
*/
let content = app.text();
console.log(content);
/* Result
Hello World!
*/
</script>
</body>
</html>