ebook img

Quick JavaScript Learning In Just 3 Days: Fast-Track Learning Course PDF

45 Pages·0.396 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Quick JavaScript Learning In Just 3 Days: Fast-Track Learning Course

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 Introduction……………………………………………4 Chapter 1: JavaScript Starts……………..…….5 Chapter 2: JavaScript Output/Display Codes……………………………………………………..9 Chapter 3: JavaScript Variables, Statements, Comments & Keywords …………………. …….14 Chapter 4: JavaScript Data Types & Operators……………………………………………….25 Chapter 5: JavaScript Functions………………32 Chapter 6: JavaScript Objects…………..….…36 Chapter 7: JavaScript Arrays……………………43 Chapter 8: JavaScript Conditions (if, else & switch) and Loops (for, while & do while).46 Summary…………………………………………………61 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. Let’s 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 don’t 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. <script> Tag JavaScript can be placed inside body and head tag. The JavaScript codes should be inside <script> and </script> tags. <script> document.getElementById(“demo”).innerHTML = “My First JavaScript Code”; </script> JavaScript Events JavaScript 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. <button onclick=“myFunction()”>Press Me!</button> Explanation – here, onclick is event and myFunction() is JS function. JavaScript Function JavaScript block of codes which is inside <script> and </script> tags which are used to perform some work is called function. <script> function myFunction(){ document.getElementById(“demo”).innerHTML = “My First JavaScript Code”; } </script> Explanation – Here myFunction() is the JS function inside <script> tags. Best Place for JS Codes It is best practice to use all JS codes inside <head> tags. <html> <head> <script> function myFunction() { document.getElementById(“demo”).innerHTML = “Paragraph has changed.”; } </script> </head> <body> <h1>New Page</h1> <p id=“demo”>This is a Paragraph</p> <button type=“button” onclick=“myFunction()”>Press Me!</button> </body> </html> Explanation – We used all script inside head tags. External JS Files You can shore all codes in one another file and save file with .js extension. You must include the file inside <head> tags by this syntax. <head> <script src=“newScript.js”></script> </head> 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 2 JavaScript Display & Output Codes JavaScript uses four ways to display output. 1st Way: document.write() It is used to write or output anything in the webpage. <html> <head> <script> function add(){ document.write(6 + 6); } </script> </head> <body> <h1>My First Code</h1> <button onclick=“add()”>Press Me!</button> </body> </html> Explanation – When you click on Press me button, document.write shows output in the webpage. 2nd Way: Window.alert() It is used to display message in alert box. <html> <body> <h1>My Alert Web Page</h1> <script> window.alert(“Warning”); </script> </body> </html> Explanation – When you open the webpage, you will see an alert box containing Warning. 3rd Way: innerHTML This method is used for writing something inside HTML element like inside paragraph, textbox, textarea and etc. <html> <head> <script> function something(){ document.getElementById(“demo”).innerHTML = “This paragraph is filled with text Now”; } </script> </head> <body>

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.