0% found this document useful (0 votes)
30 views

Topalian JavaScript Createelement Shorter Method by Christopher Topalian

Here is a shorter way to use createElement and getElementById to help make scripting easier. Instead of having to write document.createElement we can now write ce and instead of writing document.getElementById we can now write ge :-) https://github.com/ChristopherTopalian/Topalian_JavaScript_createElement_Shorter_Method
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Topalian JavaScript Createelement Shorter Method by Christopher Topalian

Here is a shorter way to use createElement and getElementById to help make scripting easier. Instead of having to write document.createElement we can now write ce and instead of writing document.getElementById we can now write ge :-) https://github.com/ChristopherTopalian/Topalian_JavaScript_createElement_Shorter_Method
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Topalian

JavaScript
createElement
Shorter
Method
by
Christopher Andrew Topalian

All Rights Reserved


Copyright 2000-2023
Dedicated
to
God the Father
<!-- Dedicated to God the Father -->

<!-- All Rights Reserved Christopher Andrew


Topalian Copyright 2000-2023 -->

<!-- https://github.com/ChristopherTopalian --
>

<!--
https://github.com/ChristopherAndrewTopalia
n -->

<!--
Topalian_createElement_Shorter_Method.htm
l -->

<!-- Version 002 -->


<html>
<head>
<title> Topalian createElement Shorter
Method </title>

<style>

body
{
padding: 10px;
background-color: rgb(50, 50, 50);
font-size: 25px;
color: rgb(255, 255, 255);
}

div
{
padding-top: 10px;
}

</style>

<script>

// document.getElementById shortcut
function ge(whichId)
{
let result =
document.getElementById(whichId);

return result;
}

// document.createElement shortcut
function ce(whichType)
{
let result =
document.createElement(whichType);

return result;
}

// document.body.append shortcut
function ba(whichElement)
{
let result =
document.body.append(whichElement);

return result;
}

function showText(whichText)
{
// if element exists
if (ge("theTextDiv"))
{
// remove the element
ge("theTextDiv").remove();
}

//-//

// create a div using shortcuts


let theTextDiv = ce("div");
theTextDiv.id = "theTextDiv";
theTextDiv.textContent = whichText;
ba(theTextDiv);
}

</script>

<body>
<button onclick = "showText('Hydrogen');"> H
</button>

<button onclick = "showText('Helium');"> He


</button>

</body>

</html>
True Artificial Intelligence System
16-Gon
Tautology
MI 1111 CI
1101 1011
AND XNOR
0001 1001
LP RP
0011 0101

OR NOR
0111 1000

RC LC
1010 1100

XOR NAND
0110 1110
CNI MNI
Contra-
0100 0010
-diction
0000
For More Tutorials:
CollegeOfScripting.weebly.com

CollegeOfScripting.wordpress.com

Youtube.com/ScriptingCollege

Twitter.com/CollegeOfScript

GitHub.com/ChristopherTopalian

GitHub.com/ChristopherAndrewTopalian

Sites.google.com/view/CollegeOfScripting
Dedicated to God the Father
This book is created by the
College of Scripting Music & Science.
Always remember, that each time you write a script
with a pencil and paper, it becomes imprinted so
deeply in memory that the material and methods are
learned extremely well.
When you Type the scripts, the same is true. The
more you type and write out the scripts by keyboard
or pencil and paper, the more you will learn
programming!
Write and Type every example that you find.
Keep all of your scripts organized.
Every script that you create increases your
programming abilities.
SEEING CODE, is one thing,
but WRITING CODE is another.
Write it, Type it, Speak It, See It, Dream It.
CollegeOfScripting.weebly.com

You might also like