1302383 Web Programming Java Script & jQuery Web Programming.

Slides:



Advertisements
Similar presentations
Computer and Communication Fundamental Basic web programming Lecture 8 Rina Zviel-Girshin.
Advertisements

JavaScript and the DOM Les Carr COMP3001 Les Carr COMP3001.
Session 11 Dynamic HTML: Event Model and Filters Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
The Web Warrior Guide to Web Design Technologies
Georgia Institute of Technology JavaScript part 2 Barb Ericson Georgia Institute of Technology May 2006.
JavaScript (Part 2) CS 183 4/13/2010. JavaScript (Part 2) Will cover: ◦ For.. In ◦ Events ◦ Try.. Catch, Throw ◦ Objects.
Chapter 7 © 2001 by Addison Wesley Longman, Inc. 1 Chapter 7 Sebesta: Programming the World Wide Web.
20-Jun-15 JavaScript and HTML Simple Event Handling.
Information Technology Center Hany Abdelwahab Computer Specialist.
Lesson 2 Event Handling. Object Event Handlers Most of the objects that make up the Document Object Model respond to asynchronous, user generated events.
JavaScript Client Side scripting. Client-side Scripts Client-side scripts, which run on the user’s workstation can be used to: Validate user inputs entered.
CST JavaScript Validating Form Data with JavaScript.
UNIT 6 JAVASCRIPT EVENT HANDLERS &WEB BROWSERS DETECTION.
CP476 Internet Computing JavaScript and HTML1 1.JavaScript Execution Environment The JavaScript Window object represents the window in which the browser.
JS: DOM Form Form Object Form Object –The Form object represents an HTML form. –For each instance of a tag in an HTML document, a Form object is created.
HTML Forms/Events (Instructor Lesson) The Event model HTML Forms Custom Events 1.
CNIT 133 Interactive Web Pags – JavaScript and AJAX Event and Event Handling.
HTML DOM.  The HTML DOM defines a standard way for accessing and manipulating HTML documents.  The DOM presents an HTML document as a tree- structure.
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
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
JavaScript – part II. The if Statement if (condition) { block of code to be executed if the condition is true }
CSS Class 7 Add JavaScript to your page Add event handlers Validate a form Open a new window Hide and show elements Swap images Debug JavaScript.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Javascript II DOM & JSON. In an effort to create increasingly interactive experiences on the web, programmers wanted access to the functionality of browsers.
Client-Side Scripting JavaScript.  produced by Netscape for use within HTML Web pages.  built into all the major modern browsers. properties  lightweight,
Intro to JavaScript Scripting language –ECMAScript compliant –Client side vs. server side Syntactic rules –White space –Statement end: ; optional –Comments:
Lecture 10 JavaScript: DOM and Dynamic HTML Boriana Koleva Room: C54
1 JavaScript 2 JavaScript. 2 Rollovers Most web page developers first use JavaScript for rollovers A rollover is a change in the appearance of an element.
Scott Marino MSMIS Summer Session Web Site Design and Authoring Session 8 Scott Marino.
Event JavaScript's interaction with HTML is handled through events that occur when the user or browser manipulates a page. When the page loads, that is.
By Tharith Sriv. To write a web page you use: HHTML (HyperText Markup Language), AASP (Active Server Page), PPHP (HyperText Preprocessor), JJavaScript,
Jaana Holvikivi 1 Introduction to Javascript Jaana Holvikivi Metropolia.
1 CSC160 Chapter 7: Events and Event Handlers. 2 Outline Event and event handlers onClick event handler onMouseOver event handler onMouseOut event handler.
Making dynamic pages with javascript Lecture 1. Java script java versus javascript Javascript is a scripting language that will allow you to add real.
Event Handling. Objectives Using event handlers Simulating events Using event-related methods.
Project 8: Reacting to Events Essentials for Design JavaScript Level One Michael Brooks.
COS 125 DAY 20. Agenda Assignment 8 not corrected yet Assignment 9 posted  Due April 16 New course time line Discussion on Scripts 
CIS 3.5 Lecture 2.3 "Introduction to JavaScript".
Copyright © Terry Felke-Morris WEB DEVELOPMENT & DESIGN FOUNDATIONS WITH HTML5 7 TH EDITION Chapter 14 Key Concepts 1 Copyright © Terry Felke-Morris.
5 th and 4 th ed: some from chapters 9, 12, 13 SY306 Web and Databases for Cyber Operations Slide Set #8: Dynamic HTML.
7. JavaScript Events. 2 Motto: Do you think I can listen all day to such stuff? –Lewis Carroll.
Understanding JavaScript and Coding Essentials Lesson 8.
JavaScript Events.
JavaScript Event Handlers. Introduction An event handler executes a segment of a code based on certain events occurring within the application, such as.
LESSON : EVENTS AND FORM VALIDATION -JAVASCRIPT. EVENTS CLICK.
Chapter 4 Java Script - Part1. 2 Outlines Introduction to Java Script Variables, Operators and Functions Conditional statements JavaScript Objects Forms.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Introduction to JavaScript Events Instructor: Sergey Goldman 1.
Functions Wouldn’t it be nice to be able to bring up a new animal and paragraph without having to reload the page each time? We can! We can place the.
.. WHAT IS JQUERY JQuery is a fast, small, and feature-rich JavaScript library. Simplifies the interaction between HTML and JavaScript. The jQuery library.
SE-2840 Dr. Mark L. Hornick 1 Dynamic HTML Handling events from DOM objects.
Methods and Object Information. Some Document Methods.
JavaScript and HTML Simple Event Handling 11-May-18.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
JavaScript Print slides by Sean Boyle, with overall content based on material provided by Dan Bogaard, from:
Week 4: Introduction to Javascript
Web Development & Design Foundations with HTML5 7th Edition
JAVASCRIPTS AND HTML DOCUMENTS
JavaScript and HTML Simple Event Handling 19-Sep-18.
JavaScript Events.
CHAPTER 7 JavaScripts & HTML Documents
..
JavaScript Intro.
JavaScript and Ajax (JavaScript Events)
Web Programming and Design
JavaScript and HTML Simple Event Handling 26-Aug-19.
JavaScript and HTML Simple Event Handling 4-Oct-19.
Presentation transcript:

Web Programming Java Script & jQuery Web Programming

Course Content Java Script Basic Java Script Framework JQuery – Core – Selector – Attributes – Traversing – Events – Effects – JQueryUI Web Programming /32

:Java Script Basic  Generate HTML Dynamically  User Events  Syntax  Function  Object & Class  Class Methods Web Programming /32

::Generate HTML Dynamically Use the tag (also use the type attribute to define the scripting language) Web Programming /32

::Referencing External JavaScript Scripts can be provided locally or remotely accessible JavaScript file using src attribute <script language="JavaScript" type="text/javascript” src=" <script language="JavaScript" type="text/javascript" src="myOwnSubdirectory/myOwn2ndJavaScript.js"> Web Programming /32

::Syntax JavaScript is dynamically typed language. var answer = 42 answer = “Thanks for all the fish…” x = "The answer is " + 42 // returns "The answer is 42" y = 42 + " is the answer" // returns "42 is the answer" "37" - 7 // returns 30 "37" + 7 // returns 377 Web Programming /32

::Function  You can call myfunction() or myfunction(20) function myfunction(value){ if (value){ this.area=value; } return this.area; } Web Programming /32

::JavaScript Popup Boxed Alert box – User will have to click "OK" to proceed – alert("sometext") Confirm box – User will have to click either "OK" or "Cancel" to proceed – confirm("sometext") Prompt box – User will have to click either "OK" or "Cancel" to proceed after entering an input value – prompt("sometext","defaultvalue") Web Programming /32

::JavaScript Language  Conditional statement  if, if.. else, switch  Loop  for loop, while loop  try...catch  throw Web Programming /32

::User Events onabort - Loading of an image is interrupted onblur - An element loses focus onchange - The content of a field changes onclick - Mouse clicks an object ondblclick - Mouse double-clicks an object onerror - An error occurs when loading a document or an image onfocus - An element gets focus onkeydown - A keyboard key is pressed Web Programming /32

:::User Events onkeypress - A keyboard key is pressed or held down onkeyup - A keyboard key is released onload - A page or an image is finished loading onmousedown - A mouse button is pressed onmousemove - The mouse is moved onmouseout - The mouse is moved off an element onmouseover - The mouse is moved over an element onmouseup - A mouse button is released Web Programming /32

:::User Events  onreset - The reset button is clicked  onresize - A window or frame is resized  onselect - Text is selected  onsubmit - The submit button is clicked  onunload - The user exits the page Web Programming /32

::::Example: onblur function upperCase() { var x=document.getElementById("fname").value document.getElementById("fname").value=x.toUpperCase() } Enter your name: Web Programming /32

::Creating a Regular Expression  Using an object initializer, as follows: re = /ab+c/  Calling the constructor function of the RegExp object, as follows: re = new RegExp("ab+c") Web Programming /32

::Example REGExp validate() function validate(obj){ var str = obj.value; myRe=/08-\d{4}-\d{4}/; var result = myRe.test(str); if(result){ obj.focus(); } Web Programming /32

::Object & Class function Person(firstname,lastname,age,eyecolor) { this.firstname=firstname; this.lastname=lastname; this.age=age; this.tellYourage=function(){ alert(“This age is ” + this.age); } Web Programming /32

:Java Script Framework jQuery : Lightweight and popular ExtJS: Rich and Comercial DoJo : Reusable in many Framework jMaki : JAVA and PHP support (Widget style) GWT :Google YUI : Yahoo Prototype mooTools Web Programming /32

:JQuery   Focus on the interaction between JavaScript and HTML  (Almost) every operation boils down to:  Find some stuff  Do something to it Web Programming /32

::Only one function!  Absolutely everything starts with a call to the jQuery() function  Since it’s called so often, the $ variable it set up as an alias to jQuery  if you’re also using another library you can revert to the previous $ function with jQuery.noConflict(); Web Programming /32

:::Hello jQuery // we will add our javascript code here Link Web Programming /32

::First jQuery function $(document).ready(function() { $("a").click(function() { alert("Hello world!"); }); Web Programming /32

::Core  each(callback)  length  eq(position)  get()  get(index)  index(subject) Web Programming /32

::Selector (Basics) Web Programming /32 SelectorUse for #idMatches a single element with the given id attribute. elementMatches all elements with the given name..classMatches all elements with the given class. *Matches all elements. selector1,sel ector2, selectorN Matches the combined results of all the specified selectors.

::Selector (Hierarchy) Web Programming /32 SelectorUse for ancestor descendantMatches all descendant elements specified by "descendant" of elements specified by "ancestor". parent > childMatches all child elements specified by "child" of elements specified by "parent". prev + nextMatches all next elements specified by "next" that are next to elements specified by "prev". prev ~ siblingsMatches all sibling elements after the "prev" element that match the filtering "siblings" selector.

::Selector (Filters) Web Programming /32 SelectorUse for :firstMatches the first selected element. :lastMatches the last selected element. :not(selector)Filters out all elements matching the given selector. :evenMatches even elements, zero-indexed. :oddMatches odd elements, zero-indexed. :eq(index)Matches a single element by its index. :gt(index)Matches all elements with an index above the given one. :lt(index)Matches all elements with an index below the given one. :headerMatches all elements headers, like h1, h2, h3 and so on. :animatedMatches all elements that are currently being animated.

Selector  See others selector at  Content filters  Visibility filters  Attribute Filters  Child filters  Forms  Form Filter Web Programming /32

::Attributes Web Programming /32 AttrUse for attr(name)Access a property on the first matched element. This method makes it easy to retrieve a property value from the first matched element. If the element does not have an attribute with such a name, undefined is returned. Attributes include title, alt, src, href, width, style, etc. attr(properties)Set a key/value object as properties to all matched elements. attr(key,value)Set a single property to a value, on all matched elements. attr(key,fn)Set a single property to a computed value, on all matched elements. removeAttr(name ) Remove an attribute from each of the matched elements.

Q & A Web Programming