Jump to content

[Tutorial] Javascript intruduction


`Rοmeο

Poll: Should i continue to write tutorials about javascript  

7 members have voted

  1. 1. Poll: Should i continue to write tutorials about javascript

    • Yes
      5
    • No
      1
    • I don't care
      1


Recommended Posts

Javascript intruduction

Before you start with Javascript you should know

-Perfect HTML

-CSS

 

 

Introduction

 

Javascript is one of the most popular scripting language in the world it is the programming language of the web for servers, PCs...

Javascript is scripting language a scripting language is a lightweight programming language

Javascript can write directly to HTML output stream react to HTML events and test HTML from input delete and create HTML elements

 

How to insert javascript in document

There are 3 ways to insert javascript code in document

1.In head tag

 

Write this in head tag

 

 

<script type="text/javascript"></script>

 

 

And here is example document

 

 

<html>
<head>
<script type="text/javascript">alert(0);</script>
</head>
<body>
</body>
</html>

 

Insert in body tag (the same as in head tag but code is write in between body tag)

Write this in the body tag

 

 

<html>
<head>
<script type="text/javascript">alert(0);</script>
</head>
<body>
</body>
</html>

 

Insert in body tag (the same as in head tag but code is write in between body tag)

Write this in the body tag

 

<script type="text/javascript"></script>

 

Here is example

 

<html>
<head>
</head>
<body>
<script type="text/javascript">alert(0);</script>
</body>
</html>

 

 

Insert from external file

Like in CSS

Write this in body tag

 

<script src="scripts.js"></script>

 

 

and write the scripts in this document

 

Manipulating HTML elements

 

You should give to your elements id for example

 

 

<p id="demo">Paragraph</p>

 

And use script ot manipulate the element

 

document.getElementById("demo").innerHTML="My first javascript";

 

So your code should look like this

 

<p id="demo">Paragraph</p>

<script>
document.getElementById("demo").innerHTML="My first javaScript";
</script>

 

When javascript is executed by the web browser in this case the browser will access the html element (id="demo") and replace its content innetHTML with "My first javascript" or what you have write

 

Write to the document output

 

write this code

 

document.write("<p> My first paragraph with javascript</p>");

 

Use document.write() to write direcly into the document output if you use document.write() after document has finish loading the entire HTML page will be overwritten

 

Statements

 

In javascript statements are commands to the browser the purpose of the statements is to tell the browser what to do

 

Example

 

 

document.getElementById("demo").innerHTML="Statement";

 

This statement tells to the browser to write "Statement" inside an HTML element with id="demo"

 

!Javascript is case sensitie there is different between function getElementById and getElementbyID or myVariable and MyVariable also javascript ignores extra spaces you can add white space ot your script to make it more readable example :

 

 

var name ="gagd"; 
var name = "fsdfs";

 

!

 

Varialbes

variable are containers for storing information

example

 

var number1 = 1;
var number2 = 2;
var number3 = 3;
var total = number1   number2   number4;

 

 

In javascript there is only one type variable (not like c  for example)

 

example :

 

var pi = 3.14;
var name = "fname lname";
var c = 'asdad';

 

and one example about variable

 

<p id="demo"></p>
var motor="Yamaha";
document.getElementById("demo").innerHTML=motor;

 

Javascript operators

 

  Addition x=2 2

- Subtraction x=5-2

* Multiplication x=3*2

/ Division x=4/2

% Modulus (division remainder) x=5%2 (result for x 1 result for y 5) lets say that y=5

  Increment x=  y ( result for x 9 result for y 9)lets say that y=5

-- Decrement decrement x=--y (result for =5 result for y =4)lets say that y=5

= x=y

<= x<=y

>= x>=y

= x =y same as x=x y

-= x-=y same as x=x-y

*= x*=y same as x=x*y

/  x/=y same as x=x/y

%= x%=y same as x=x%y

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Instead of using encedc on it, try renaming it to "Icon.u" instead of "Icon.utx", and put it in your System folder. If it still crashes, the problem might be with your unrealed.
    • How's the project doing? Is there any news? It really interesting 🤔
    • thx for answer, i tried and woks encrypting, but i still having crashes 😞 i changed the icon in skillgrp.dat from "icon.skill0003" to "Myicons.misil" as i saved the file before endec and nothing. this is the report i got
    • New Season coming May 2024! First post updated      Website: L2Kain.net  Discord: https://discord.gg/l2kain  Wiki: https://info.kain.ws/   Important Dates   Server Start: TBD  Open Beta Test: 10th of May 2024!   Basic Information     Briefly about the concept of the server! We decided to move away from the standard Mid-Rate server concept and keep the mechanics of our beloved Lineage 2 that everyone loves! Massive battles for epic bosses, battles for profitable farming locations, resource spoilage and equipment crafting, daily instances, a balanced economy and much more. This server is build as a Craft-PvP concept. The goal is to gather players with a variety of preferences in the game and make a high-quality and interesting server with alternative character development options. We are well aware that "grinding" is an integral part of the game, but we diluted the boring and the same type of farming with interesting solutions and non-standard mechanics!   We have prepared a new High Five x25 on Modern Client for you. This server will be another step in the development of the platform and the project as a whole! Your appeals to those. support was not ignored, which means the new server will be even better than the previous one!      ⭐ Promotions and Bonuses for new players!     ⭐ Events and Giveaways daily!   ⭐ Rewards for Voting!   ℹ️ Server Rates Learn more about server rates! Server rates are configured in such a way that farming is best rewarded. Adena, drops, quests, various rewards and prices in the game store are well balanced among themselves!   Basic Server Rates:  ⭐ Experience & Skill Points - x25  ⭐ Adena Drop - x15 & Fixed Chance 66%  ⭐ Drop Rates - x10  ⭐ Spoil Rates - x10   Crafting keys, recipes drop & spoil with fixed amount from 2 to 3 and increased chances on all locations and quests  related to farm them.  ⭐ Quest Rates - x5  ⭐ Fortresses & Sieges - x5  ⭐ Raid Bosses & Epic Bosses - x1  ⭐ Weight Limit - x10      Connect with Us:  Discord: https://discord.gg/l2kain  Facebook: https://www.facebook.com/KainLineage2  TikTok: https://www.tiktok.com/@l2kain.net  YouTube: https://www.youtube.com/@Lineage2Kain
  • Topics

×
×
  • Create New...