jquery nasrullah. jquery jquery is a javascript library. jquery greatly simplifies javascript...

16
Jquery Nasrullah

Upload: alexia-hunt

Post on 13-Jan-2016

225 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Jquery

Nasrullah

Page 2: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Jquery

• jQuery is a JavaScript Library.

• jQuery greatly simplifies JavaScript programming.

• jQuery is easy to learn

Page 3: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Why JQuery

Many of the biggest companies on the Web use jQuery, such as:

1. Google2. Microsoft3. IBM4. Netflix

Page 4: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Download JQuery

• The jQuery library is a single JavaScript file, and you reference it with the HTML

• <head>< script src="jquery-1.9.1.min.js"></script>< /head>

Page 5: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Alternatives to Downlaoding

• If you don't want to download and host jQuery yourself, you can include it from a CDN (Content Delivery Network).

• Both Google and Microsoft host jQuery.• To use jQuery from Google or Microsoft, use one of the following:• <head>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">< /script>< /head>

• <head>< script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.9.1.min.js">< /script>< /head>

Page 6: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

What is Jquery

• 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, and wraps them into methods that you can call with a single line of code.

• jQuery also simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation

Page 7: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

J query libray features

• HTML/DOM manipulation• CSS manipulation• HTML event methods• Effects and animations• AJAX• Utilities

Page 8: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Locate the User Position

• The HTML5 Geolocationt API is used to get the geographical position of a user.

Page 9: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Jquery syntax• The jQuery syntax is made for selecting HTML

elements and performing some action on the element(s).

• Basic syntax is: $(selector).action()

1. A $ sign to define/access jQuery

2. A (selector) to "query (or find)" HTML elements

3. A jQuery action() to be performed on the element(s)

Page 10: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Using GeoLocation

• Use the getCurrentPosition() method to get the user's position

• The navigator object contains information about the browser

• Navigator.geolocation• Navigator.appname;• Navigator.platform

Page 11: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

• $(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".

Page 12: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Document Ready

• You might have noticed that all jQuery methods are inside a document ready event

• $(document).ready(function(){ // jQuery methods go here...});

This is to prevent any jQuery code from running before the document is finished loading (is ready).• It is good practice to wait for the document to be fully loaded and ready

before working with it. This also allows you to have your JavaScript code before the body of your document, in the head section. Here are some examples of actions that can fail if methods are run before the document is fully loaded:

• Trying to hide an element that is not created yet• Trying to get the size of an image that is not loaded yet

Page 13: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

Jquery Syntax for Event Methods• All the different visitor's actions that a web page

can respond to are called events moving a mouse over an element selecting a radio button clicking on an element

$("p").click();

$("p").click(function(){ // action goes here!!});

Page 14: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn
Page 15: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn

• Use the getCurrentPosition() method to get the user's position• Navigator.geolocation.getCurrentPositio

n(

Page 16: Jquery Nasrullah. Jquery jQuery is a JavaScript Library. jQuery greatly simplifies JavaScript programming. jQuery is easy to learn