Javascript? What is javascript and how do we use it?
- markcholloway0304

- Jul 11, 2023
- 1 min read
What is Javascript and how do we use it?
Javascript is a coding language that you can make click events, more events! or even Events that will execute when every time a user starts the website.
When Javascript executes 2 codes when a user starts the website, it will quickly disappear, Sometimes.
But how do we use it? Well, Let's do a basic one.
Copy and paste this code in Javascript.
function myClickEvent() {
alert("You clicked the Rickroll button!");
}
function printMe() {
window.print();
}
Now with HTML.
But before we do that
Put this html tag wrapped up in the head tag.
<script type="text/javascript" src="myJavascript.js"></script>
Now let's do the HTML:
<html>
<head>
<script type="text/javascript" src="myJavascript.js"></script>
</head>
<body>
<a href="#" onclick="myClickEvent()">Rickroll</a>
<a href="#" onclick="printMe()">Print this Page</a>
</body>
</html>
Now here's the preview of our javascript, html webpage!
And now, still there are some basics to do here...
You need to add this in your myJavascript.js (javascript) file!
Javascript:
function TruthOrLie() {
confirm("Did you eat my Cookies i baked?");
}
function TextDialog() {
prompt("Leave a message :D");
}
We need to add some links or buttons to do these 2 functions above. Use HTML.
<a href="#" onclick="TruthOrLie()">WE GOT A QUESTION!!!</a>
<a href="#" onclick="TextDialog()">Send a Message</a>
Our HTML Preview:
That's all you need to know about Javascript Basics! LOL!!!!



Comments