jquery

16

Upload: guest1f6f380f

Post on 13-Jan-2015

556 views

Category:

Entertainment & Humor


3 download

DESCRIPTION

Jquery hassan

TRANSCRIPT

Page 1: Jquery
Page 2: Jquery

DOM tree and main objects What is jQuery Selectors Attributes CSS Events Animation Other helper functions plug-ins Tools and inspectors links

Page 3: Jquery

<p title="The test paragraph">This is a sample of some <b>HTML you might<br>have</b> in your document</p>

To access Dom tree nodes› document.getElementById('id of paragraph') › document.getElementsByTagName('p')[indexOfParagraph]› window.document.childNodes[0].childNodes[1].childNodes[4]

Page 4: Jquery

Winodw› Main properties and methods:

Alert() Close() Document Location Open() Print() resizeTo() scrollTo() innerWidth, innerHeight

Page 5: Jquery

Document› Main properties and methods:

getElementById(id) getElementsByName(name) getElementsByTagName(name) Forms Images

Page 6: Jquery

Element var imgObj = document.getElementById('img1');

› Main properties and methods:› attributes[]› childNodes[]› className› innerHTML

Page 7: Jquery

Just another framework Browser compatibility VS support

Page 8: Jquery

By ID : $('#id'); By class : $(‘.id'); By tag : $(‘tag')[index]; By property: (“tag[property=‘value']") More:

› http://docs.jquery.com/Selectors

Page 9: Jquery

Read attribute: $("em").attr("title"); Set attribute: $("em").attr("title”,”hello”); Set multimple attributes:

$("img").attr({ src: "/images/hat.gif", title: "jQuery", alt: "jQuery Logo" });

Set class: $("p:last").addClass("selected"); Read/set html: $(“#id”).html(); - $

(“#id”).html(‘html value’); Read/set text: $(“#id”).text(); - $

(“#id”).text(‘text value’);

Page 10: Jquery

Read/set CSS: › $(this).css({'background-color‘});› $(this).css({'background-color' : 'yellow',

'font-weight' : 'bolder'}); Offset:

› $(this).offset().left , $(this).offset().top position:

› $(this).position().left , $(this). position().top

Page 11: Jquery

Click:› $("p").click(function () { alert($(this).text()); });

Toggle:$("li").toggle( function () { $(this).css({"list-style-type":"disc", "color":"blue"}); }, function () { $(this).css({"list-style-type":"disc", "color":"red"}); }, function () { $(this).css({"list-style-type":"", "color":""}); } );

Page 12: Jquery

Show› $("button").click(function () { $("p").show("slow"); });

Hide› $(" button").click(function () {

$(this).hide(); }); Animate:

› $("button").click(function () { $(" button ").animate({

width: "70%", opacity: 0.4, marginLeft: "0.6in", fontSize: "3em", borderWidth: "10px" }, 1500 );});

More: http://docs.jquery.com/Effects

Page 13: Jquery

Document ready:$(document).ready(function() { // put all your jQuery goodness in here.});

ForeachjQuery.each(arr, function() { $("#" + this).text("My id is " + this + "."); return (this != "four"); // will stop running

to skip "five" });

Page 14: Jquery
Page 15: Jquery

FireBug IE developer toolbar VS debugging

Page 16: Jquery

 http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx

http://www.learningjquery.com/ http://docs.jquery.com http://jquery.com/plugins/ http://getfirebug.com/ http://www.microsoft.com/downloadS/details.aspx?

familyid=E59C3964-672D-4511-BB3E-2D5E1DB91038&displaylang=en