The Script Tag
The script tag is an iconic tag in HTML5, just like the style tag you can edit live JavaScript right in HTML! Here is an example:
<script>
document.write("Hello, World!");
</script>
Welcome to the tutorial. In this tutorial, I'll try to teach you most of the stuff I know about
The script tag is an iconic tag in HTML5, just like the style tag you can edit live JavaScript right in HTML! Here is an example:
<script>
document.write("Hello, World!");
</script>
Inorder to import jQuery you must write this: <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
. Heres an example.
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
In JavaScript, has 3 types of variable commands:
const
let
var
Like for example; say I wanted to make PI a constructor all I'd have to do is write this: const PI = Math.PI
. And when I do that then this would make PI a constructor and the value would be PI [diameter of a circle 3.14
].
In jQuery, you can change CSS values with jQuery. Like this:
$(function() {
$(".box").css({
"background-color": "black",
"color": "white",
"padding": "15px",
"font-family": "roboto, sans-serif"
});
});
Have you ever heard of HTML DOM? I'm not there yet in the tutorial but I'm getting there. Like this: document.getElementById();
.
var demo = document.getElementById("demo");
demo.innerHTML = "<p><Hello, World!/p>";
If you've ever wanted to animate stuff using JavaScript but you just can't find out how? Well tryout jQuery: https://code.jquery.com/jquery-3.6.0.min.js. Heres a basic replica of the animate function:
$("div").animate({
width: "100px"
});
Click the button in the iframe to change the value of the background color of the iframe.
jQuery has a select few options to fiddle with like for one instance the fade
method.
$("div").fadeOut(1000);
Yea, I know I should have introduced this first. But whatever. But you can change HTML values in just the type of a keyboard.
$(".btnONE").click(function() {
$(".Start").html("Go!");
});
In JavaScript, you can create objects like this: var person = { name: "John", age: 52, height: 5'7, weight: "150 pounds" }
.
var fruits = [
'Apple',
'Orange',
'Pear',
'Passion Fruit',
'Starfruit',
'Peach',
'Grapefruit'
]
HTML DOM is a JavaScript processer where you can edit HTML5 through JavaScript.
function changeMe(me) {
me.style.background = "black";
me.innerText = "JavaScript";
me.style.color = "red"
}
The jQuery fadetoggle method allows you to make stuff fade in and out on click.
As you see the title says: Date & Time (jQuery & JavaScript)
. Okay, now now lets focus on the date and time. Here's the first code snippet:
jQuery
$(function() {
var time = $(".time");
const date = new Date();
let hours = date.getHours();
let minutes = date.getMinutes();
let seconds = date.getSeconds();
var timeVal = hours + ":" + minutes + ":" + seconds;
time.html(timeVal);
});
I'm too lazy to make another code snippet, so here it is in the code box.
JavaScript
Welcome to the end of the JavaScript & JQuery Tutorial, at the end of the tutorial we greet you with a HTML, CSS, & JS code editor! Enjoy!! We also include: C++, PHP, & JSON. They don't work on the iframe though. You just get to edit the text!
"; const HTML = document.getElementById("html"); const CSS = document.getElementById("css"); const JS = document.getElementById("js"); $("#btnRunner").click(function() { PROGRAM.open(); PROGRAM.writeln(HTML.value + "" + "