jquery anica
TRANSCRIPT
-
7/31/2019 Jquery Anica
1/39
Naresh Information
Technologies
-
7/31/2019 Jquery Anica
2/39
jQuery Nagaraju Bende
MCPD.NET Sr Consultant,Trainer
http://nbende.wordpress.com
http://nbende.wordpress.com/http://nbende.wordpress.com/ -
7/31/2019 Jquery Anica
3/39
JavaScript is a weakly typed, classless,
prototype based OO language, that
can also be used outside the
browser. It is not a browser DOM.
About JAvascript
-
7/31/2019 Jquery Anica
4/39
The worlds most misunderstood
programming language.
Most People Say
-
7/31/2019 Jquery Anica
5/39
With AJAX Javascript has become essential to current
web page development, but
Javascript is not a good language design
Javascript has become bloated DOM navigation
Browser differences
Writing Javascript code is tedious, time-
consuming, and error-prone
-
7/31/2019 Jquery Anica
6/39
jQuery is a lightweight, open-source
JavaScript library that simplifies
interaction between HTML and
JavaScript
jQuery
-
7/31/2019 Jquery Anica
7/39
It was and still being
developed
by John Resigfrom
Mozilla and was
first announced inJanuary 2006
-
7/31/2019 Jquery Anica
8/39
with jQuery
jQuery makes writing Javascript mucheasier
DOM navigation (css-like syntax)
Apply methods to sets of DOM elements
Builder model (chain method calls)
Extensible and there are tons of libraries
Handles most browser differences so you dont
have to Server provides data
jQuery on client provides presentation
-
7/31/2019 Jquery Anica
9/399
jQuery Technicality
Lightweight 14kb (Minified and Gzipped) Cross-browser support (IE 6.0+, FF 1.5+,
Safari 2.0+, Opera 9.0+)
CSS-like syntax easy for developers/non-developers to understand
Active developer community
Extensible - plugins
-
7/31/2019 Jquery Anica
10/3910
Example Ajax the old wayfunction GetXmlHttpObject(handler) {
var objXmlHttp = null; //Holds the local xmlHTTP object instance
//Depending on the browser, try to create the xmlHttp objectif (is_ie){
var strObjName = (is_ie5) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
try{
objXmlHttp = new ActiveXObject(strObjName);
objXmlHttp.onreadystatechange = handler;
}catch(e){
//Object creation errored
alert('Verify that activescripting and activeX controls are enabled');
return;
}
}
else{
// Mozilla | Netscape | Safari
objXmlHttp = new XMLHttpRequest();
objXmlHttp.onload = handler;
objXmlHttp.onerror = handler;
}
//Return the instantiated object
return objXmlHttp;
-
7/31/2019 Jquery Anica
11/3911
Example Ajax with jQuery
$.get("update_actions.aspx", {st: "yes", f: $(this).attr("ID")} );
-
7/31/2019 Jquery Anica
12/39
$(#firstName).text(Joe Black);
$(button).click(function() {alert Clicked;});
$(.content).hide();
$(#main).load(content.htm);
$().html(Loading).appendTo(#content);
A Quality code by Query:
Very compact and fluent programming model
-
7/31/2019 Jquery Anica
13/39
Download the latest version from
http://jquery.com
http://jquery.com/http://jquery.com/ -
7/31/2019 Jquery Anica
14/39
To enable itellisense in VS 2008 SP1
install thevsdoc hotfix:VS90SP1-KB958502-x86.exe
http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736http://code.msdn.microsoft.com/KB958502/Release/ProjectReleases.aspx?ReleaseId=1736 -
7/31/2019 Jquery Anica
15/39
Copy thejquery.js
and the
jquery-vsdoc.js
into your application
folder
-
7/31/2019 Jquery Anica
16/39
jQuery Core Concepts
-
7/31/2019 Jquery Anica
17/39
Create HTML elements on the fly
var el = $()
$() function runs the total show
-
7/31/2019 Jquery Anica
18/39
Manipulate existing DOM elements
$(window).width()
$() function
-
7/31/2019 Jquery Anica
19/39
Selects document elements
(more in a moment)
$(div).hide();
$(div, $(p)).hide();
$() function
-
7/31/2019 Jquery Anica
20/39
$(document).ready(function(){});
Fired when the document is ready forprogramming.
Better use the full syntax:
$(function(){});
$() function
-
7/31/2019 Jquery Anica
21/39
No need to reference thevsdoc.js
Reference it in your markup
-
7/31/2019 Jquery Anica
22/39
or just drag it into the file
///
Reference it in your JS files:
-
7/31/2019 Jquery Anica
23/39
You can also reference it from Google
-
7/31/2019 Jquery Anica
24/39
$(div).hide()
$().appendTo(body)
$(:button).click()
jQuerys programming philosophy is:
GET >> ACT
-
7/31/2019 Jquery Anica
25/39
$(*) // find everything
All Selector
Selectors return a pseudo-array of jQuery
elements
-
7/31/2019 Jquery Anica
26/39
$(div)
// Hello jQuery
Basic Selectors
Yes, jQuery implements CSS Selectors!
$(#usr)
// John
$(.menu)
// Home
By Tag:
By ID:
By Class:
-
7/31/2019 Jquery Anica
27/39
$(div.main) // tag and class
$(table#data) // tag and id
More Precise Selectors
-
7/31/2019 Jquery Anica
28/39
-
7/31/2019 Jquery Anica
29/39
$(table td) // descendants
$(tr > td) // children
$(label + input) // next
$(#content ~ div) // siblings
Hierarchy Selectors
-
7/31/2019 Jquery Anica
30/39
$(tr:first) // first element
$(tr:last) // last element
$(tr:lt(2)) // index less than
$(tr:gt(2)) // index gr. than
$(tr:eq(2)) // index equals
Selection Index Filters
-
7/31/2019 Jquery Anica
31/39
Effects using
jQuery
-
7/31/2019 Jquery Anica
32/39
// just show
$(div).show();
// reveal slowly, slow=600ms
$(div).show(slow);
// hide fast, fast=200ms
$(div).hide(fast);
// hide or show in 100ms
$(div).toggle(100);
Showing or Hiding Element
-
7/31/2019 Jquery Anica
33/39
$(div).slideUp();
$(div).slideDown(fast);
$(div).slideToggle(1000);
Sliding Elements
-
7/31/2019 Jquery Anica
34/39
$(div).fadeIn(fast);
$(div).fadeOut(normal);
// fade to a custom opacity
$(div).fadeTo (fast, 0.5);
Fading Elements
Fading === changing opacity
-
7/31/2019 Jquery Anica
35/39
$(div).hide(slow, function() {
alert(The DIV is hidden);
});
$(div).show(fast, function() {
$(this).html(Hello jQuery);
});// this is a current DOM element
Detecting animation completion
Every effect function has a (speed, callback)
overload
-
7/31/2019 Jquery Anica
36/39
// .animate(options, duration)
$(div).animate({
width: 90%,opacity: 0.5,
borderWidth: 5px
}, 1000);
Custom Animation
-
7/31/2019 Jquery Anica
37/39
EFFECTS DEMO
-
7/31/2019 Jquery Anica
38/39
$(div).load(content.htm);
// passing parameters
$(#content).load(getcontent.aspx,
{id:33,
type:main});
Loading content
-
7/31/2019 Jquery Anica
39/39
Useful jQuery links
www.jquery.com jQuery homepage www.learningjquery.com jQuery tutorial
blog
www.visualjquery.com jQuerydocumentation
http://ui.jquery.com jQuery user interface
http://bassistance.de/jquery-plugins/ -
homepage of the author of several useful
jQuery plugins.
http://www.jquery.com/http://www.learningjquery.com/http://www.visualjquery.com/http://ui.jquery.com/http://bassistance.de/jquery-plugins/http://bassistance.de/jquery-plugins/http://bassistance.de/jquery-plugins/http://bassistance.de/jquery-plugins/http://ui.jquery.com/http://www.visualjquery.com/http://www.learningjquery.com/http://www.jquery.com/