jquery

42
Presentation On JQuery Prepared By Rahul Jain Lexcis Solution

Upload: rahuljain003

Post on 27-Jan-2015

605 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: JQuery

Presentation On JQuery

Prepared By

Rahul Jain Lexcis Solution

Page 2: JQuery

Agenda

• Basics of Jquery• Javascript vs Jquery  • Why to use Jquery• Concept of Jquery • Overview of jquery API• Jquery pros and cons• Jquery programs • Conclusion

Page 3: JQuery

What exactly is jQuery

jQuery is a JavaScript Library!

• Dealing with the DOM• JavaScript Events• Animations• Ajax interactions

Page 4: JQuery

jQuery Basics jQuery()This function is the heart of the jQuery libraryYou use this function to fetch elements using CSS selectorsand wrap them in jQuery objects so we can manipulatethem

There’s a shorter version of the jQuery() function: $()$("h1");$(".important");

Page 5: JQuery

Document Ready

$(document).ready(function(){// Your code here});jQuery has a simple statement that checks thedocument and waits until it's ready to be manipulated

Page 6: JQuery

What’s the problem with JavaScript?

Page 7: JQuery

JavaScript is a weakly typed,

classless, prototype based OO

language, that can also be

used outside the browser. It is

not a browser DOM.

Page 8: JQuery

It means no more of this

var tables = document.getElementsByTagName("table");for (vart = 0; t<tables.length; t++) {var rows = tables[t].getElementsByTagName("tr"); for (vari = 1; i<rows.length; i += 2) { if (!/(^|s)odd(s|$)/.test(rows[i].className)) {

rows[i].className += " odd"; } }};

Page 9: JQuery

Using jQuery we can do this

$("tabletr:nth-child(odd)").addClass("odd");

Page 10: JQuery

Using jQuery we can do this

jQuery("tabletr:nth-child(odd)").addClass("odd");

jQuery function

Page 11: JQuery

Using jQuery we can do this

jQuery("tabletr:nth-child(odd)").addClass("odd");

jQuery function

jQuery Selector (CSS expression)

Page 12: JQuery

Using jQuery we can do this

jQuery("tabletr:nth-child(odd)").addClass("odd");

jQuery function

jQuery Selector (CSS expression)

jQuery Wrapper Set

Page 13: JQuery

Using jQuery we can do this

jQuery("tabletr:nth-child(odd)").addClass("odd");

jQuery function

jQuery Selector (CSS expression)

jQuery MethodjQuery Wrapper Set

Page 14: JQuery

It really is the

“write less, do more”

JavaScript Library!

Page 15: JQuery

Why use jQuery

• Helps us to simplify and speed up web development• Allows us to avoid common headaches associated with browser development• Provides a large pool of plugins• Large and active community• Tested on 50 browsers, 11 platforms• Its for both coders and designers

Page 16: JQuery

Get > Act

Chainability

The $() function

Three Major Concepts of jQuery

Page 17: JQuery

Create HTML elements on the fly

var el = $(“<div/>”)

The Magic $() function

Page 18: JQuery

Manipulate existing DOM elements

$(window).width()

The Magic $() function

Page 19: JQuery

Selects document elements(more in a moment…)

$(“div”).hide();

$(“div”, $(“p”)).hide();

The Magic $() function

Page 20: JQuery

$(document).ready(function(){…});

Fired when the document is ready for programming.

Better use the full syntax:

$(function(){…});

The Magic $() function

Page 21: JQuery

$(“div”).hide()

$(“<span/>”).appendTo(“body”)

$(“:button”).click()

jQuery’s programming philosophy is:

GET >> ACT

Page 22: JQuery

$(“div”).show() .addClass(“main”) .html(“Hello jQuery”);

Almost every function returns jQuery, which provides a fluent

programming interface and chainability:

Page 23: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

Page 24: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

jQuery()

each() map()size()lengthselectorcontextindex()get()

Page 25: JQuery

Overview of jQuery API

jQuery("#nav li.contact")

jQuery(":visible")

jQuery(":radio:enabled:checked")

jQuery("a[title]")

jQuery("a[title][href='foo']")

jQuery("a:first[href*='foo']")

jQuery("#header, #footer")

jQuery("#header, #footer").filter(":visible")

CoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

Page 26: JQuery

Overview of jQuery API

attr()removeAttr()

addClass()hasClass()toggleClass()removeClass()

val()

CoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

Page 27: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

add()children()closest()find()next()nextAll()prev() prevAll() siblings()

parent() parents()

andSelf()end()

eq()filter()is()not()slice()

Page 28: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

html()text()

append()appendTo()prepend()prependTo()

after()insertAfter()before()insertBefore()

wrap()wrapAll()wrapInner()

replaceWith()replaceAll()

empty()remove()

clone()

Page 29: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

css()

offset()offsetParent()postion()scrollTop()scrollLeft()

height()width()innerHeight()innerWidth()outerHeight()outerWidth()

Page 30: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

blur()change()click()dbclick()error()focus()keydown()keypress()keyup()mousedown()mousenter()mouseleave()mouseout()mouseup()resize()scroll()select()submit()unload()

ready()

bind()one()trigger()triggerHandler()unbind()

live()die()

hover()toggle()

Page 31: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

show()hide()toggle()

slideDown()slideUp()slideToggle()

fadeIn()fadeOut()fadeTo()

animate()stop()

Page 32: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

jQuery.ajax()jQuery.get()jQuery.getJSON()jQuery,getScript() jQuery.post()

load()

ajaxComplete()ajaxError()ajaxSend()ajaxStart()ajaxStop()ajaxSuccess()

jQuery.ajaxSetup() serialize()serializeArray()

Page 33: JQuery

Overview of jQuery APICoreSelectorsAttributesTraversingManipulationCSSEventsEffectsAjaxUtilities

jQuery.supportjQuery.boxModel

jQuery.each(), jQuery.extend(), jQuery.grep(), jQuery.makeArray(), jQuery.map(), jQuery.inArray(), jQuery.merge(), jQuery.unique()

jQuery.isArray(), jQuery,isFunction()

jQuery.trim()

jQuery.param()

Page 34: JQuery

A Few Examples

FormsChatboxesMenusDropdownsSlidersTabsSlideshowsGames

Page 35: JQuery

jQuery Enhanced Forms

Page 36: JQuery

Menus and Dropdowns

Page 37: JQuery

Sliders and Slideshows

Page 38: JQuery

Technical Implementation

Building Real-Time Form Validation Using jQuery

Page 39: JQuery

Pros:

• Large Community• Ease of use• Large library• Strong opensource community. (Several jQuery plugins available) • Great documentation and tutorials• Ajax support

Page 40: JQuery

Cons:• Regular updates that change existing behaviour• Overhead of adding extra javascript to page• Learning curve may not be short for some developers

Conclusions:• Conclusion In the end, jquery is popular for a reason. It will make your website easier to control and to access through any browser.• By using this library, you can create or include complex plug-ins in a matter of minutes. This will make your website easier to use and as long as you have imagination, the possibilities are endless.

Page 41: JQuery

Any Queries??...

Page 42: JQuery

Thank You