♚
|♚|KK|♚|
Guest
I plan to start with JavaScript, because I've started learning it recently. But I will try to include other languages too later on, if I can.^^
These lessons are from SoloLearn, (so most of the image and text source will be from there) a community for teaching and learning coding using many languages. And I will add my own notes of course, plus my thoughts so tag along!
-JavaScript-
Let's start with taking a look of what is the meaning of this language.
-JavaScript is one of the most popular programming languages on earth and is used to add interactivity to webpages, process data, as well as create various applications (mobile apps, desktop apps, games, and more)
So with this language you can use to create interactive web elements!
Now let's try creating our first JS.
Let's use JavaScript to print "Hello World" to the browser.
Output
The document.write() function writes a string into our HTML document. This function can be used to write text, HTML, or both.
The above code displays the following result:
Formatting Text
Just like in HTML, we can use HTML tags to format text in JavaScript.
For example, we can output the text as a heading.
Result:
JavaScript in <head>
You can place any number of scripts in an HTML document.
Typically, the script tag is placed in the head of the HTML document:
JavaScript in <body>
Alternatively, include the JavaScript in the <body> tag.
The <script> Tag
The <script> tag can take two attributes, language and type, which specify the script's type:
In the example below, we created an alert box inside the script tag, using the alert() function.
Result:
JavaScript in <head>
You can place any number of scripts in an HTML document.
Typically, the script tag is placed in the head of the HTML document:
JavaScript in <body>
Alternatively, include the JavaScript in the <body> tag.
The <script> Tag
The <script> tag can take two attributes, language and type, which specify the script's type:
In the example below, we created an alert box inside the script tag, using the alert() function.
Result:
++will add more content soon!:D
These lessons are from SoloLearn, (so most of the image and text source will be from there) a community for teaching and learning coding using many languages. And I will add my own notes of course, plus my thoughts so tag along!
-JavaScript-
Let's start with taking a look of what is the meaning of this language.
-JavaScript is one of the most popular programming languages on earth and is used to add interactivity to webpages, process data, as well as create various applications (mobile apps, desktop apps, games, and more)
Note: Learning the fundamentals of a language will enable you to create the program you desire, whether client-side or server-side.
So with this language you can use to create interactive web elements!
Now let's try creating our first JS.
Let's use JavaScript to print "Hello World" to the browser.
Output
Code:
<html>
<head> </head>
<body>
<script>
document.write("Hello World!");
</script>
</body>
</html>
The document.write() function writes a string into our HTML document. This function can be used to write text, HTML, or both.
The above code displays the following result:
Note: The document.write() method should be used only for testing. Other output mechanisms appear in the upcoming lessons.
Formatting Text
Just like in HTML, we can use HTML tags to format text in JavaScript.
For example, we can output the text as a heading.
Code:
<html>
<head> </head>
<body>
<[U]script[/U]>
document.write("[B]<h1>[/B]Hello World![B]</h1>[/B]");
</script>
</body>
</html>
Result:
JavaScript in <head>
You can place any number of scripts in an HTML document.
Typically, the script tag is placed in the head of the HTML document:
Code:
<html>
<head>
<script>
</script>
</head>
<body>
</body>
</html>
Alternatively, include the JavaScript in the <body> tag.
Code:
<html>
<head> </head>
<body>
<script>
</script>
</body>
</html>
Note: It's a good idea to place scripts at the bottom of the <body> element.
This can improve page load, because HTML display is not blocked by scripts loading.
This can improve page load, because HTML display is not blocked by scripts loading.
The <script> Tag
The <script> tag can take two attributes, language and type, which specify the script's type:
Code:
<script language="javascript" type="text/javascript">
</script>
Note: The language attribute is deprecated, and should not be used.
In the example below, we created an alert box inside the script tag, using the alert() function.
Code:
<html>
<head>
<title></title>
<script type="text/javascript">
alert("This is an alert box!");
</script>
</head>
<body>
</body>
</html>
Result:
Note: The type attribute: <script type="text/javascript"> is also no longer required, as JavaScript is the default HTML scripting language.
JavaScript in <head>
You can place any number of scripts in an HTML document.
Typically, the script tag is placed in the head of the HTML document:
Code:
<html>
<head>
<script>
</script>
</head>
<body>
</body>
</html>
Alternatively, include the JavaScript in the <body> tag.
Code:
<html>
<head> </head>
<body>
<script>
</script>
</body>
</html>
Note: It's a good idea to place scripts at the bottom of the <body> element.
This can improve page load, because HTML display is not blocked by scripts loading.
This can improve page load, because HTML display is not blocked by scripts loading.
The <script> Tag
The <script> tag can take two attributes, language and type, which specify the script's type:
Code:
<script language="javascript" type="text/javascript">
</script>
Note: The language attribute is deprecated, and should not be used.
In the example below, we created an alert box inside the script tag, using the alert() function.
Code:
<html>
<head>
<title></title>
<script type="text/javascript">
alert("This is an alert box!");
</script>
</head>
<body>
</body>
</html>
Result:
++will add more content soon!:D
Last edited: