Javascript and JQuery SRM DSC.

Slides:



Advertisements
Similar presentations
JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Advertisements

HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
Introduction to JavaScript. Aim To enable you to write you first JavaScript.
ITM352 Javascript and Dynamic Web Pages: Client Side Processing.
Definition from Wikipedia.  The Prototype JavaScript Framework  implemented as a single file of JavaScript code  named prototype.js (
JavaScript Teppo Räisänen LIIKE/OAMK HTML, CSS, JavaScript HTML defines the structure CSS defines the layout JavaScript is used for scripting It.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
A really fairly simple guide to: mobile browser-based application development (part 4, JQuery & DOM) Chris Greenhalgh G54UBI / Chris Greenhalgh.
Event Handlers CS101 Introduction to Computing. Learning Goals Learn about event handlers Determine how events are useful in JavaScript Discover where.
Chapter 19: Adding JavaScript
DOM and JavaScript Aryo Pinandito.
DHTML: Dynamic HTML Internet Technology1. What is DHTML? A collection of enhancements to HTML ► To create dynamic and interactive websites Combination.
Section 17.1 Add an audio file using HTML Create a form using HTML Add text boxes using HTML Add radio buttons and check boxes using HTML Add a pull-down.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
Animation & Effects Using JQuery. What is jQuery? jQuery is a lightweight, JavaScript library. The purpose of jQuery is to make it much easier to use.
JavaScript - A Web Script Language Fred Durao
Cs332a_chapt10.ppt CS332A Advanced HTML Programming DHTML Dynamic Hypertext Markup Language A term describing a series of technologies Not a stand-a-lone.
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2 Revised by Dr. T. Tran for CSI3140.
JavaScript Library. What is jQuery jQuery is a lightweight JavaScript library. The purpose is to make it easier to use JavaScript code on your website.
JQuery JavaScript is a powerful language but it is not always easy to work with. jQuery is a JavaScript library that helps with: – HTML document traversal.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
JavaScript Defined DOM (Document Object Model) General Syntax Body vs. Head Variables Math & Logic Selection Functions & Events Loops Animation Getting.
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Unit 13 –JQuery Basics Instructor: Brent Presley.
Understanding JavaScript and Coding Essentials Lesson 8.
Document Object Model Nasrullah. DOM When a page is loaded,browser creates a Document Object Model of the Page.
Introduction to JQuery COGS 187A – Fall JQuery jQuery is a JavaScript library, and allows us to manipulate HTML and CSS after the page has been.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
CSCI 3100 Tutorial 5 JavaScript & Ajax Jichuan Zeng Department of Computer Science and Engineering The Chinese University of Hong.
JQuery is a fast, small, and feature-rich javascript library. It makes things like HTML document traversal and manipulation, event handling, animation,
JQuery.
Introduction to.
DHTML.
Javascript and Dynamic Web Pages: Client Side Processing
Programming Web Pages with JavaScript
Week 3: Introduction to Javascript
>> JavaScript: Document Object Model
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Unit M Programming Web Pages with
12/04/12 JQuery I took these slides from the site because they were pretty good looking. Instructions for editing school and department titles: Select.
Tek Raj Chhetri Code for Humans not for machine.
Week 4: Introduction to Javascript
Human Computer Interaction
Concepts of HTML, CSS and Javascript
JavaScript Event Handling.
Unit M Programming Web Pages with
Intro to JavaScript CS 1150 Spring 2017.
Introduction to Web programming
Section 17.1 Section 17.2 Add an audio file using HTML
Web Development & Design Foundations with HTML5 7th Edition
JQUERY Online TRAINING AT GOLOGICA
Section 10.1 YOU WILL LEARN TO… Define scripting
DHTML Javascript Internet Technology.
JQuery with ASP.NET.
DHTML Javascript Internet Technology.
Introduction to Programming the WWW I
..
E-commerce Applications Development
Document Object Model.
Computer communications
Chengyu Sun California State University, Los Angeles
Introduction to JavaScript & jQuery
Front End Development workshop
Web Client Side Technologies Raneem Qaddoura
Web Programming and Design
Web Programming and Design
Presentation transcript:

Javascript and JQuery SRM DSC

What happens when you do the following ? Enter text in a text box Click on a button Click on links Submit a form All of these are events … Some code gets executed in the background in response to a users interaction with the web page. This code is nothing but your javascript ... It defines what actions has to be taken in response to various interactions of the user.

What is Javascript ? JavaScript is a scripting language that enables you to Create dynamically updating content Control multimedia Respond to events Animate images, and pretty much everything else. (Okay, not everything, but it is amazing what you can achieve with a few lines of JavaScript code.)

The <script> Tag HTML, JavaScript code must be inserted between <script> and </script> tags. There are two ways of adding javascript code to the HTML file using the script tags : Directly add code between the script tags Eg . <html> <head></head> <body> <script> console.log(“hello world !”); </script> </body> </html> Create a javascript file with .js extension (Eg. app.js) and refer to this file in the script tag Eg : <body><script type= ”text/javascript” src= “path to your js file/app.js”></script></body>

Some Javascript intensive websites https://patatap.com/ http://paperjs.org/ https://d3js.org/ http://animejs.com/ https://howlerjs.com/

What you will learn JS Arrays , Objects DOM Handling events A simple counter game JQuery To do List for Harry Potter

Javascript console A tool that developers use to record/ log the output of their programs To open javascript console : Open chrome developer tools (ctrl+shift+i) and go to the console tab

Input and output 1. console. log() - logs data in the console 2 Input and output 1.console.log() - logs data in the console 2. alert () 3. prompt () - take input from user

Arrays

Objects Objects are collections of attributes and functions , the attributes can be of different types. Eg - here we have an object with string , number , and array of strings as its attribute type

Document Object Model (DOM) The HTML DOM model is constructed as a tree of Objects: With the object model, JavaScript gets all the power it needs to create dynamic HTML: JavaScript can change all the HTML elements in the page JavaScript can change all the HTML attributes in the page JavaScript can change all the CSS styles in the page JavaScript can remove existing HTML elements and attributes JavaScript can add new HTML elements and attributes JavaScript can react to all existing HTML events in the page JavaScript can create new HTML events in the page

DOM TREE EXMAPLE Consider the following html code < DOM TREE EXMAPLE Consider the following html code <!DOCTYPE html> <html> <head> <title>Page Title</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="en-us" /> </head> <body> <h1>This is a heading</h1> <p>A paragraph with a <a href="http://www.google.com/">link</a>.</p> <ul> <li>a list item</li> <li>another list item</li> <li>a third list item</li> </ul> </body> </html>

DOM Tree - every node of the tree is a HTML element

Finding HTML Elements 1. document Finding HTML Elements 1. document.getElementById ( id ) - Find an element by element id 2. document.getElementsByTagName ( tag name ) - Find elements by tag name 3. document.getElementsByClassName ( class name ) - Find elements by class name 4. document.querySelector ( css selector ) - find first of the set of elements found by valid css selectors 5. document.querySelectorAll ( css selector ) - find the set of all elements found by valid css selectors

Adding and Deleting Elements document Adding and Deleting Elements document.createElement (element) - Create an HTML element document.removeChild (element) - Remove an HTML element document.appendChild (element) - Add an HTML element document.replaceChild (element) - Replace an HTML element

Changing HTML Style To change the style of an HTML element, use this syntax: document.getElementById(id).style.property = new style Eg : document.getElementById(‘btn1’).style.color=’red’; Changing Attribute of HTML element To change the attribute of an HTML element, use this syntax: document.getElementById(id).attribute = new value Eg : document.getElementById(‘Myimage’).src=’hagrid.jpg’;

DOM Events A JavaScript can be executed when an event occurs, like when a user clicks on an HTML element. Examples of HTML events: When a user clicks the mouse When a web page has loaded When an image has been loaded When the mouse moves over an element When an input field is changed When an HTML form is submitted When a user strokes a key

Player count game

What is JQuery and why use JQuery ? jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.

JQuery Syntax

Change css of element using Jquery

JQuery syntax to change the HTML of element

To do List for Harry Potter

Resources to learn Javascript and JQuery https://www.javascript.com/ https://www.w3schools.com/js/ https://www.w3schools.com/jquery/jquery_intro.asp https://learn.jquery.com/