top of page

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

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!!!!

ree

 
 
 

Recent Posts

See All
Why students disagree with homework?

Because it cause students stress, and it wastes student's time to play. And students, all around the globe, disagrees homework. Here are...

 
 
 
Make your own blog!

Make your own article... Hmm... We don't need JavaScript, We need HTML and CSS!!!! Here's CSS, for style.css. p::first-letter {...

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page