Quick JavaScript Learning In Just 3 Days (Fast-Track Learning Course) By Vijay K. R. Disclaimer Copyright By Vijay K. R. The publisher and the author of this publication have utilized their best efforts to maintain the accuracy of all the contents. The content in this eBook is intended to be used only for educational purposes.
No part of this eBook can be copied, reconstructed or rewritten by any means, electronic, Photostat or by any mode, without the written consent of the author and the publisher. The readers are completely responsible for all the actions taken by reading the content of this book. The author and the publisher hold no responsibility for any damage, loss or disruption because of omissions or errors, to any party. The author and the publisher disclaim any liability regarding the effectiveness, performance or applicability of anything in this eBook. Table of Content ...5 ..9 .....14 .25 ...36 .46 Introduction JavaScript is one the language which helps you make browser to do what you want to do. This is easy language to learn and I am going to teach you now.
My language will be user friendly and I will try to tell difficult stuffs in easy language with examples. Lets move on one by one with JavaScript lessons. This is 3 days basic JavaScript Learning Course. Before starting JavaScript, I am assuming that you have at least basic knowledge of HTML & CSS. If you dont have knowledge of HTML & CSS, then you should go and study that first via online tutorials. You may be able to learn basic HTML & CSS in 2-3 days.
Day 1 = Learn Chapter 1 & 2 Day 2 = Learn Chapter 3, 4 & 5 Day 3 = Learn Chapter 6, 7 & 8 Chapter 1 JavaScript Basics JavaScript can change HTML Contents. If you are PHP developer and if you want to get done some work without page loads or you want HTML & CSS to perform work then you will need JavaScript. Tag
JavaScript can be placed inside body and head tag. The JavaScript codes should be inside and tags.document.getElementById("demo").innerHTML = "My First JavaScript Code";JavaScript EventsJavaScript codes are triggered on events. Events are performed when a person perform an event. There are many events provided by browser like onclick, onmouseover, onkeyup, onkeydown, ondoubleclick and many more.
When any of events performs then JS Codes triggered and do something according to codes.Press Me!Explanation here, onclick is event and myFunction() is JS function.JavaScript FunctionJavaScript block of codes which is inside and tags which are used to perform some work is called function.function myFunction(){document.getElementById("demo").innerHTML = "My First JavaScript Code";}Explanation Here myFunction () is the JS function inside tags.
Best Place for JS Codes
It is best practice to use all JS codes inside tags.
function myFunction() {
document.getElementById("demo").innerHTML = "Paragraph has changed.";
}
New Page
This is a ParagraphPress Me!Explanation We used all script inside head tags.External JS FilesYou can shore all codes in one another file and save file with .js extension. You must include the file insidetags by this syntax.Explanation Here, we used newScript.js file, where we stored all JS codes, when any function is invoked the codes will be triggered directly from the newScript.js file.Chapter 2JavaScript Display & Output CodesJavaScript uses four ways to display output.st Way: document.write()It is used to write or output anything in the webpage.function add(){document.write(6 + 6);}My First Code
Press Me!Explanation When you click on Press me button, document.write shows output in the webpage.nd Way: Window.alert()It is used to display message in alert box.My Alert Web Page
window.alert("Warning");Explanation When you open the webpage, you will see an alert box containing Warning.rd Way: innerHTMLThis method is used for writing something inside HTML element like inside paragraph, textbox, textarea and etc.function something(){document.getElementById("demo").innerHTML = "This paragraph is filled with text Now";}Write Inside HTML Element Paragraph
P is blank nowPress Me!Explanation when you click Press Me, document . getElementById takes id demo and writes inside demo id through innerHTML keyword.th Way: console.log()It is used to write inside console, click on F12 function key in your firefox, chrome, IE browser. You will see one console tag. Click on tab, you will get the message which you write in console.log(). See example.console.log(2+2);Click F12 function key and go to console tag to see results
Chapter 3JavaScript Variables, Statements, Comments, KeywordsJavaScript VariablesVariables are used to stored data in any language.
In JavaScript, variables do the same like C and other high languages. Variables are stored in the form of data types like int, str and etc. however at JS, you can use var keyword for all types of data types.Writing String : For writing string, you need to use single or double quote.Example:var x = This is a Boy.;var y = This is a Girl.;Note: semi colon ; is used to end the line.Writing Numeric : For writing numeric, you need not to use double or single quotes. If you use it then JS will take it as string.Example:var x = 8;var y = 6;
Next page