Elements toggleText() - KirkGarcia182/domExtend GitHub Wiki
The element's innerHTML is switched between the two passed parameter texts.
element.toggleText(text1 ,text2);
text1 - A String
representing the text that will be switched between text2.
text2 - A String
representing the text that will be switched between text1.
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');
app.html('Hello World');
app.toggleText('Hello World', 'Good Day');
console.log(app);
/* Result
<div id="app">
Good Day
</div>
*/
app.toggleText('Hello World', 'Good Day');
console.log(app);
/* Result
<div id="app">
Hello World
</div>
*/
</script>
</body>
</html>