Elements html() - KirkGarcia182/domExtend GitHub Wiki
Sets or gets the innerHTML of an element
// sets the innerHTML of an element
element.html(text);
// gets the innerHTML of an element
element.html();
If you're getting the element's innerHTML then it will return the value of it's innerHTML.
If you're setting the element's innerHTML then it will return the element you just manipulated so you can chain these methods.
<!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');
// setting an element's innerHTML
app.html('Hello World!');
console.log(app);
/* Result
<div id="app">
Hello World!
</div>
*/
// getting an element's innerHTML
let innerHTML = app.html();
console.log(innerHTML);
/* Result
Hello World!
*/
</script>
</body>
</html>