Jquery Anica
Jquery Anica
jQuery
Nagaraju Bende
MCPD.NET Sr Consultant,Trainer
http://nbende.wordpress.com
About
JAvascript
can also be used outside the
With A
JAX
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
jQuery
jQuery is a lightweight, open-source JavaScript library that simplifies interaction between HTML and
JavaScript
It was and still being developed by John Resig from Mozilla and was
first announced in
January 2006
with jQuery
jQuery makes writing Javascript much easier
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
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/nondevelopers to understand Active developer community Extensible - plugins
10
11
$(.content).hide();
$(#main).load(content.htm); $(<div/>).html(Loading).appendTo(#content);
http://jquery.com
Copy the
jquery.js
and the jquery-vsdoc.js into your application folder
var el = $(<div/>)
$() function
$(window).width()
Manipulate existing DOM elements
$() function
$(div).hide();
$(div, $(p)).hide();
Selects document elements (more in a moment)
$() function
$(function(){});
Fired when the document is ready for programming. Better use the full syntax:
$(document).ready(function(){});
<script src=jquery.js/>
///<reference path=jquery.js/>
$(div).hide() $(<span/>).appendTo(body)
$(:button).click()
All Selector
$(*)
// find everything
Basic Selectors
By Tag: $(div) // <div>Hello jQuery</div>
By ID:
$(#usr)
// <span id=usr>John</span>
By Class:
$(.menu)
// <ul class=menu>Home</ul>
$(div.main)
Combination of Selectors
// find by id + by class $(#content, .menu) // multiple combination $(h1, h2, h3, div.content)
Hierarchy Selectors
$(table td) $(tr > td) $(label + input) $(#content ~ div) // descendants // children // next // siblings
Sliding Elements
$(div).slideUp(); $(div).slideDown(fast); $(div).slideToggle(1000);
Fading Elements
$(div).fadeIn(fast); $(div).fadeOut(normal); // fade to a custom opacity $(div).fadeTo (fast, 0.5);
Custom Animation
// .animate(options, duration) $(div).animate({ width: 90%, opacity: 0.5, borderWidth: 5px
}, 1000);
EFFECTS DEMO
Loading content
$(div).load(content.htm);