Top Banner
jQuery WEB ENGINEERING By: Muhammad Adeel
19

jQuery - Web Engineering

Apr 14, 2017

Download

Technology

adeel990
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: jQuery - Web Engineering

jQueryWEB ENGINEERING

By: Muhammad Adeel

Page 2: jQuery - Web Engineering

jQuery

• jQuery is a JavaScript Library.

• jQuery greatly simplifies JavaScript programming.

• jQuery is easy to learn.

Page 3: jQuery - Web Engineering

Before Studying jQuery You should Know:

Step 1 HTML

Step 2 CSS

Step 3 JavaSc

ript

Page 4: jQuery - Web Engineering

Purpose

• jQuery is a lightweight, "write less, do more", JavaScript library.

• The purpose of jQuery is to make it much easier to use JavaScript on your website.

• jQuery takes a lot of common tasks that require many lines of JavaScript code to accomplish, you can call with a single line of code.

• Many of the biggest companies on the Web use jQuery, such as: Google, Microsoft, IBM, Netflix.

Page 5: jQuery - Web Engineering

Adding jQuery to your Web Pages

• Just go to your browser and write jquery.com

Page 6: jQuery - Web Engineering

Adding jQuery to your Web Pages (cont.)

• Now Go to the Downloads Options as shown below

• Now Scroll down the page, at the end of the Web page you will found “Past Releases”. Just Click on jQuery CDN.

• Now you will see different versions of jQuery Core, You click on See all version of jQuery Core.

Page 7: jQuery - Web Engineering

Adding jQuery to your Web Pages (cont.)

STEP 1

STEP 2

Page 8: jQuery - Web Engineering

Adding jQuery to your Web Pages (cont.)

• When you uncompressed it, new tab will be open automatically with JavaScript/jQuery code.

• Press Ctrl + A then Ctrl + C, then Paste it on Notepad and save as file name: jquery.js and save as type: All files.

Page 9: jQuery - Web Engineering

How to Refer jQuery ?

• The jQuery library is a single JavaScript file,• and you reference it with the HTML <script> tag• (notice that the <script> tag should be inside the <head>

section):

<head><script src="jquery.js"></script></head>

Page 10: jQuery - Web Engineering

Functions In a Separate File

• <head><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><script src="my_jquery_functions.js"></script></head>

Page 11: jQuery - Web Engineering

jQuery Syntax

• $(selector).action()

$(this).hide() - hides the current element.$("p").hide() - hides all <p> elements.$(".test").hide() - hides all elements with class="test".$("#test").hide() - hides the element with id="test".

METHODS

Page 12: jQuery - Web Engineering

jQuery Method

• all jQuery methods in our examples, are inside a document ready event:

• $(document).ready(function(){

   // jQuery methods go here...

});

Page 13: jQuery - Web Engineering

The #id Selector

• $(document).ready(function(){  $("button").click(function(){    $("#test").hide();  });});

<!DOCTYPE html><html><head><script src="jquery.js"></script><script>$(document).ready(function(){ $("button").click(function(){ $("#test").hide(); });});</script></head>

<body><h2>This is a heading</h2><p>This is a paragraph.</p><p id="test">This is another paragraph.</p><button>Click me</button></body>

</html>

Page 14: jQuery - Web Engineering

Events Occur in jQuery

Page 15: jQuery - Web Engineering

Mouse hover Event

• $("#p1").hover(function(){  alert("You entered p1!");  },  function(){  alert("Bye! You now leave p1!");});

Page 16: jQuery - Web Engineering

Focus event

• $("input").focus(function(){  $(this).css("background-color","#cccccc");});

Page 17: jQuery - Web Engineering

jQuery Effects - Fading

• jQuery has the following fade methods:• fadeIn() - fades in a hidden element.• fadeOut()-fades out a visible element.• fadeToggle()- toggles between the fadeIn() and

fadeOut() methods• fadeTo()-allows fading to a given opacity (value

between 0 and 1).

Page 18: jQuery - Web Engineering

jQuery Effects - Sliding

• slideDown() - slides down an element.• slideUp() - slides up an element• slideToggle() - toggles between the slideDown()

and slideUp() 

Page 19: jQuery - Web Engineering

THANK YOU….