• No results found

jQuery <3 Developers

N/A
N/A
Protected

Academic year: 2021

Share "jQuery <3 Developers"

Copied!
128
0
0

Loading.... (view fulltext now)

Full text

(1)
(2)

Who, what, why of jQuery

Core concepts of jQuery

API overview & tips

Plugin design pattern

News

Live demo

(3)
(4)
(5)
(6)

Who?

reddit.com

espn.com

ibm.com

stackoverflow.com

boxee.tv

bit.ly

twitpic.com

whitehouse.gov

microsoft.com

amazon.com

netflix.com

bing.com

monster.com

tv.com

overstock.com

time.com

capitalone.com

wordpress.com

dell.com

twitter.com

w3.org

http://trends.builtwith.com/javascript/jquery

(7)

What?

Selector engine: Sizzle

DOM manipulation

Events

Effects

Ajax

(8)
(9)

It means no more of this

var tables = document.getElementsByTagName('table'); for (var t = 0; t < tables.length; t++) {

! var rows = tables[t].getElementsByTagName('tr'); ! for (var i = 1; i < rows.length; i += 2) {

if (!/(^|s)odd(s|$)/.test(rows[i].className)) { rows[i].className += ' odd';

} } }

(10)

jQuery simplifies

(11)

jQuery simplifies

jQuery

('table tr:nth-child(odd)').addClass('odd');

(12)

jQuery simplifies

jQuery('

table tr:nth-child(odd)

').addClass('odd');

jQuery function

(13)

jQuery simplifies

jQuery('table tr:nth-child(odd)')

.

addClass('odd')

;

jQuery function

CSS expression

(14)

jQuery simplifies

(15)

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

(16)

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

(17)
(18)

APIs

docs.jquery.com

api.jquery.com

visualjquery.com

Blogs, tutorials, screencasts,

plugins, development sprints

Google Groups

jquery-en

jquery-dev

jquery-ui-en

jquery-ui-dev

jquery-a11y

IRC channel

irc.freenode.net/#jquery

Twitter

@jquery

@jquerysites

@jqueryui

Help!

(19)

APIs

docs.jquery.com

api.jquery.com

visualjquery.com

Blogs, tutorials, screencasts,

plugins, development sprints

Google Groups

jquery-en

jquery-dev

jquery-ui-en

jquery-ui-dev

jquery-a11y

IRC channel

irc.freenode.net/#jquery

Twitter

@jquery

@jquerysites

@jqueryui

Help!

(20)

Concept 1:

knowing the jQuery

parameter types

(21)

CSS selectors & custom CSS expressions

HTML

DOM elements

(22)

CSS selectors & custom CSS expressions

HTML

DOM elements

A function (shortcut for DOM ready)

(23)

CSS selectors & custom CSS expressions

HTML

DOM elements

A function (shortcut for DOM ready)

jQuery(‘div’) & jQuery(‘:first’)

(24)

CSS selectors & custom CSS expressions

HTML

DOM elements

A function (shortcut for DOM ready)

jQuery(‘div’) & jQuery(‘:first’)

jQuery(‘<li><a href=”#”>link</a></li>’)

(25)

CSS selectors & custom CSS expressions

HTML

DOM elements

A function (shortcut for DOM ready)

jQuery(‘div’) & jQuery(‘:first’)

jQuery(‘<li><a href=”#”>link</a></li>’)

jQuery(document) or jQuery(document.createElement(‘a’))

jQuery(function(){}) =

(26)

CSS selectors & custom CSS expressions

HTML

DOM elements

A function (shortcut for DOM ready)

jQuery(‘div’) & jQuery(‘:first’)

jQuery(‘<li><a href=”#”>link</a></li>’)

jQuery(document) or jQuery(document.createElement(‘a’))

jQuery(function(){}) =

(27)

Concept 2:

find something,

do something

(28)

<!DOCTYPE html>

<html>

<body>

<ul id="nav">

<li><a>home</a></li>

<li><a>about</a></li>

</ul>

</body>

</html>

(29)

<!DOCTYPE html>

<html>

<body>

<ul id="nav">

<li><a>home</a></li>

<li><a>about</a></li>

</ul>

<script src="jquery.js"></script>

</body>

</html>

(30)

<!DOCTYPE html>

<html>

<body>

<ul id="nav">

<li>

<a>home</a>

</li>

<li>

<a>about</a>

</li>

</ul>

<script src="jquery.js"></script>

<script>

jQuery('#nav li');

</script>

</body>

</html>

(31)

<!DOCTYPE html>

<html>

<body>

<ul id="nav">

<li

class="item"

><a>home</a></li>

<li

class="item"

><a>about</a></li>

</ul>

<script src="jquery.js"></script>

<script>

jQuery('#nav li')

.addClass('item');

</script>

</body>

(32)

Concept 3:

create something,

do something

(33)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

</ul>

</body>

</html>

(34)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘<li>home</li>’);

jQuery(‘<li>about</li>’);

</script>

</body>

</html>

(35)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li>home</li>

<li>about</li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘<li>home</li>’)

.appendTo(‘#nav’);

jQuery(‘<li>about</li>’)

.appendTo(‘#nav’);

</script>

</body>

</html>

(36)

createDocumentFragment

Inside

tip

(37)

createDocumentFragment

Inside

tip

(IE6 || IE7) &&

innerHTML && HTML5

==

fail

(38)

Concept 4:

(39)

<!DOCTYPE html>

<html>

<body>

<ul

id='nav'

>

<li

class=”item”

><a href=”/home”>home</a></li>

<li

class=”item”

><a href=”/about”>about</a></li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘ul’).attr(‘id’, ‘nav’);

jQuery(‘#nav li’).addClass(‘item’);

jQuery(‘#nav a’).each(function () {

jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());

});

</script>

</body>

</html>

(40)

<!DOCTYPE html>

<html>

<body>

<ul

id='nav'

>

<li

class=”item”

><a href=”/home”>home</a></li>

<li

class=”item”

><a href=”/about”>about</a></li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘ul’).attr(‘id’, ‘nav’);

jQuery(‘#nav li’).addClass(‘item’);

jQuery(‘#nav a’).each(function () {

jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());

});

</script>

</body>

</html>

1

1

(41)

<!DOCTYPE html>

<html>

<body>

<ul

id='nav'

>

<li

class=”item”

><a href=”/home”>home</a></li>

<li

class=”item”

><a href=”/about”>about</a></li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘ul’).attr(‘id’, ‘nav’);

jQuery(‘#nav li’).addClass(‘item’);

jQuery(‘#nav a’).each(function () {

jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());

});

</script>

</body>

</html>

1

1

2

2

(42)

<!DOCTYPE html>

<html>

<body>

<ul

id='nav'

>

<li

class=”item”

><a href=”/home”>home</a></li>

<li

class=”item”

><a href=”/about”>about</a></li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘ul’).attr(‘id’, ‘nav’);

jQuery(‘#nav li’).addClass(‘item’);

jQuery(‘#nav a’).each(function () {

jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());

});

</script>

</body>

</html>

1

1

2

2

3

3

(43)

<!DOCTYPE html>

<html>

<body>

<ul

id='nav'

>

<li

class=”item”

><a href=”/home”>home</a></li>

<li

class=”item”

><a href=”/about”>about</a></li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘ul’).attr(‘id’, ‘nav’);

jQuery(‘#nav li’).addClass(‘item’);

jQuery(‘#nav a’).each(function () {

jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());

});

</script>

</body>

</html>

(44)

<!DOCTYPE html>

<html>

<body>

<ul

id='nav'

>

<li

class=”item”

><a href=”/home”>home</a></li>

<li

class=”item”

><a href=”/about”>about</a></li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘ul’)

.attr(‘id’, ‘nav’)

.find(‘li’)

.addClass(‘item’)

.find(‘a’)

.each(function () {

jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());

});

</script>

</body>

</html>

(45)

jQuery returns itself

containing the current

DOM collection

(46)

Concept 5:

understanding

implicit iteration

(47)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>

<a href=”/home”>home</a>

</li>

<li class=”item”>

<a href=”/about”>about</a>

</li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘ul’)

.attr(‘id’, ‘nav’)

.find(‘li’)

.addClass(‘item’)

.find(‘a’)

.each(function () {

jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());

});

</script>

</body>

</html>

(48)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>

<a href=”/home”>home</a>

</li>

<li class=”item”>

<a href=”/about”>about</a>

</li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘ul’)

.attr(‘id’, ‘nav’)

.find(‘li’)

.addClass(‘item’)

.find(‘a’)

.each(function () {

jQuery(this).attr(‘href’, ‘/’+jQuery(this).text());

});

</script>

</body>

</html>

(49)

Knowing the jQuery parameter types

Find something, do something

Create something, do something

Chaining & Operating

Understanding Implicit Iteration

(50)

“What about the

bling function?”

(51)
(52)
(53)
(54)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>home</li>

<li class=”item”>about</li>

</ul>

<script src=”jquery.js”></script>

<script>

jQuery(‘li’).addClass(‘item’);

</script>

</body>

</html>

(55)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>home</li>

<li class=”item”>about</li>

</ul>

<script src=”jquery.js”></script>

<script>

</script>

</body>

</html>

jQuery(‘li’).addClass(‘item’);

(56)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>home</li>

<li class=”item”>about</li>

</ul>

<script src=”jquery.js”></script>

<script>

</script>

</body>

</html>

$(‘li’).addClass(‘item’);

(57)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>home</li>

<li class=”item”>about</li>

</ul>

<script src=”jquery.js”></script>

<script>

$(‘li’).addClass(‘item’);

</script>

</body>

</html>

(58)
(59)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>home</li>

<li class=”item”>about</li>

</ul>

<script src=”jquery.js”></script>

<script>

$(‘li’).addClass(‘item’);

</script>

</body>

</html>

(60)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>home</li>

<li class=”item”>about</li>

</ul>

<script src=”jquery.js”></script>

<script>

$(document).ready(function () {

$(‘li’).addClass(‘item’);

});

</script>

</body>

</html>

(61)

<!DOCTYPE html>

<html>

<body>

<ul id='nav'>

<li class=”item”>home</li>

<li class=”item”>about</li>

</ul>

<script src=”jquery.js”></script>

<script>

$(document).ready(function () {

$(‘li’).addClass(‘item’);

});

</script>

</body>

</html>

(62)

$(document).ready(function () {

$(‘li’).addClass(‘item’);

});

(63)

$(

document).ready

(function () {

$(‘li’).addClass(‘item’);

});

(64)

$(function () {

$(‘li’).addClass(‘item’);

});

(65)

jQuery

(function (

$

) {

$(‘li’).addClass(‘item’);

});

(66)

Tip

(67)
(68)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

(69)

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

jQuery()

each()

size()

eq()

get()

index()

length

selector

context

data()

removeData()

queue()

dequeue()

jQuery.fn.extend()

jQuery.extend()

jQuery.noConflict()

Core

(70)

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

jQuery()

each()

size()

eq()

get()

index()

length

selector

context

data()

removeData()

queue()

dequeue()

jQuery.fn.extend()

jQuery.extend()

jQuery.noConflict()

Core

(71)

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

<!DOCTYPE html>

<html>

<body>

<p>Element Node</p>

<script src="jquery.js">

</script>

<script>

alert($('p').get(0).nodeName);

</script>

</body>

</html>

Core

http://jsbin.com/ibito/edit

(72)

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

<!DOCTYPE html>

<html>

<body>

<p>Element Node</p>

<script src="jquery.js">

</script>

<script>

alert($('p').get(0).nodeName);

alert($('p')[0].nodeName);

</script>

</body>

</html>

Core

http://jsbin.com/idiyi/edit

(73)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

(74)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

$(‘#nav li.contact’)

(75)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

$(‘#nav li.contact’)

$(‘:visible’)

(76)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

$(‘#nav li.contact’)

$(‘:visible’)

$(‘:radio:enabled:checked’)

(77)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

$(‘#nav li.contact’)

$(‘:visible’)

$(‘:radio:enabled:checked’)

$(‘a[title]’)

(78)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

$(‘#nav li.contact’)

$(‘:visible’)

$(‘:radio:enabled:checked’)

$(‘a[title]’)

$(‘a[title][hash*=”foo”]’)

(79)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

$(‘#nav li.contact’)

$(‘:visible’)

$(‘:radio:enabled:checked’)

$(‘a[title]’)

$(‘a[title][hash*=”foo”]’)

$(‘a:first[hash*=”foo”]’)

(80)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

$(‘#nav li.contact’)

$(‘:visible’)

$(‘:radio:enabled:checked’)

$(‘a[title]’)

$(‘a[title][hash*=”foo”]’)

$(‘a:first[hash*=”foo”]’)

$(‘.header, .footer’)

(81)

Core

Attributes

Traversing

Manipulation

CSS

Events

Effects

Ajax

Utilities

Selectors

$(‘#nav li.contact’)

$(‘:visible’)

$(‘:radio:enabled:checked’)

$(‘a[title]’)

$(‘a[title][hash*=”foo”]’)

$(‘a:first[hash*=”foo”]’)

$(‘.header, .footer’)

(82)

getElementById

getElementsByTagName

getElementsByClassName

querySelectorAll

Inside

tip

Performance

(83)

getElementById

getElementsByTagName

getElementsByClassName

querySelectorAll

Inside

tip

Performance

jQuery selec

tors

fail silently

,

(84)

Core

Selectors

Attributes

Manipulation

CSS

Events

Effects

Ajax

Utilities

Traversing

add()

children()

closest()

contents()

find()

next()

nextAll()

offsetParent()

parent()

parents()

prev()

prevAll()

siblings()

andSelf()

end()

eq()

filter()

is()

map()

not()

slice()

(85)

Core

Selectors

Attributes

Manipulation

CSS

Events

Effects

Ajax

Utilities

Traversing

add()

children()

closest()

contents()

find()

next()

nextAll()

offsetParent()

parent()

parents()

prev()

prevAll()

siblings()

andSelf()

end()

eq()

filter()

is()

map()

not()

slice()

New in

1.3

(86)

Core

Selectors

Attributes

Manipulation

CSS

Events

Effects

Ajax

Utilities

Traversing

add()

children()

closest()

contents()

find()

next()

nextAll()

offsetParent()

parent()

parents()

prev()

prevAll()

siblings()

andSelf()

end()

eq()

filter()

is()

map()

not()

slice()

Searches

down

(87)

Core

Selectors

Attributes

Manipulation

CSS

Events

Effects

Ajax

Utilities

Traversing

add()

children()

closest()

contents()

find()

next()

nextAll()

offsetParent()

parent()

parents()

prev()

prevAll()

siblings()

andSelf()

end()

eq()

filter()

is()

map()

not()

slice()

Filters

across

(88)

Core

Selectors

Attributes

Manipulation

CSS

Events

Effects

Ajax

Utilities

Traversing

add()

children()

closest()

contents()

find()

next()

nextAll()

offsetParent()

parent()

parents()

prev()

prevAll()

siblings()

andSelf()

end()

eq()

filter()

is()

map()

not()

slice()

(89)

Core

Selectors

Attributes

Manipulation

CSS

Events

Effects

Ajax

Utilities

Traversing

<!DOCTYPE html><html><body>

<ul>

<li><a>one</a></li>

<li><a>two</a></li>

<li><a>three</a></li>

</ul>

<script src="jquery.js">

</script>

<script>

$('a').click(function () {

alert( $(this)

.parent()

.prevAll()

.length

)

});

</script>

</body></html>

http://jsbin.com/ubuhe/edit

(90)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Effects

Ajax

Utilities

Events

ready()

bind()

one()

trigger()

triggerHandler()

unbind()

live()

die()

hover()

toggle()

load()

unload()

error()

blur()

change()

click()

dbclick()

focus()

keydown()

keypress()

keyup()

mousedown()

mousenter()

mouseleave()

mouseout()

mouseup()

resize()

scroll()

select()

submit()

(91)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Effects

Ajax

Utilities

Events

ready()

bind()

one()

trigger()

triggerHandler()

unbind()

live()

die()

hover()

toggle()

load()

unload()

error()

blur()

change()

click()

dbclick()

focus()

keydown()

keypress()

keyup()

mousedown()

mousenter()

mouseleave()

mouseout()

mouseup()

resize()

scroll()

select()

submit()

IE fires on blur

(92)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Effects

Ajax

Utilities

Events

ready()

bind()

one()

trigger()

triggerHandler()

unbind()

live()

die()

hover()

toggle()

load()

unload()

error()

blur()

change()

click()

dbclick()

focus()

keydown()

keypress()

keyup()

mousedown()

mousenter()

mouseleave()

mouseout()

mouseup()

resize()

scroll()

select()

submit()

(93)

<!DOCTYPE html>

<html>

<body>

<p>1. click</p>

<p>2. click</p>

<script src="jquery.js"></script>

<script>

$(‘p’).

bind

(‘click’, function(){

$(this).after(‘<p>’ +

➥ $(this).text()+‘ clicked</p>’);

});

</script>

</body>

</html>

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Effects

Ajax

Utilities

Events

http://jsbin.com/ededi/edit

(94)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Effects

Ajax

Utilities

Events

<!DOCTYPE html>

<html>

<body>

<p>1. click</p>

<p>2. click</p>

<script src="jquery.js"></script>

<script>

$(‘p’).

live

(‘click’, function(){

$(this).after(‘<p>’ +

➥ $(this).text()+‘ clicked</p>’);

});

</script>

</body>

</html>

http://jsbin.com/ihalu/edit

(95)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Ajax

Utilities

Effects

$.fx.off

show()

hide()

toggle()

slideDown()

slideUp()

slideToggle()

fadeIn()

fadeOut()

fadeTo()

animate()

stop()

(96)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Ajax

Utilities

Effects

$.fx.off

show()

hide()

toggle()

slideDown()

slideUp()

slideToggle()

fadeIn()

fadeOut()

fadeTo()

animate()

stop()

Blanket FX control

New in

(97)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Ajax

Utilities

Effects

$.fx.off

show()

hide()

toggle()

slideDown()

slideUp()

slideToggle()

fadeIn()

fadeOut()

fadeTo()

animate()

stop()

(98)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Ajax

Utilities

Effects

<!DOCTYPE html><html><head>

<style>

div {background:#bca; width:100px;

border:1px solid green;}

</style>

</head>

<body>

<div id="block">Hello!</div>

<script src="jquery.js"></script>

<script>

$(‘#block’)

.animate({

! width: ‘70%’,

! opacity: 0.4,

! marginLeft: ‘0.6in’,

! fontSize: ‘3em’,

! borderWidth: ‘10px’

}, 1500)

;

</script></body></html>

http://jsbin.com/oroto/edit

(99)
(100)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Effects

Utilities

Ajax

$.ajax()

$.get()

$.post()

$.getJSON()

$.getScript()

$.ajaxSetup()

load()

serialize()

serializeArray()

ajaxCompete()

ajaxError()

ajaxSend()

ajaxStart()

ajaxStop()

ajaxSuccess()

(101)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Effects

Utilities

Ajax

$.ajax()

$.get()

$.post()

$.getJSON()

$.getScript()

$.ajaxSetup()

load()

serialize()

serializeArray()

ajaxCompete()

ajaxError()

ajaxSend()

ajaxStart()

ajaxStop()

ajaxSuccess()

(102)

Core

Selectors

Attributes

Traversing

Manipulation

CSS

Events

Effects

Utilities

Ajax

<!DOCTYPE html><html><body>

<script src="jquery.js">

</script>

<script>

$.getJSON("http://twitter.com/

statuses/user_timeline.json?

screen_name=rem&callback=?",

function(data){

$.each(data,function(i,tweet){

$('<p/>').html

(tweet.text).appendTo('body');

if ( i == 30 ) return false;

});

});

</script></body></html>

http://jsbin.com/acisi/edit

(103)
(104)

What’s a plugin?

A plugin is nothing more than a custom

jQuery method created to extend the

functionality of the jQuery object

(105)
(106)

Step 1:

create a private

scope for $ alias

(107)

<!DOCTYPE html><html><body> <script src=”jquery.js”></script> <script> (function ($) { })(jQuery); </script></body></html>

(108)

Step 2:

attach plugin to fn

alias (aka prototype)

(109)

<!DOCTYPE html><html><body> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }; // end of plugin })(jQuery); </script></body></html>

(110)

<!DOCTYPE html><html><body>

<p>I hate jQuery!</p>

<script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }; // end of plugin })(jQuery); $(‘p’).notHate(); </script></body></html>

(111)

Step 3:

(112)

<!DOCTYPE html><html><body>

<p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p>

<script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { this.each(function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }); }; // end of plugin })(jQuery); $(‘p’).notHate(); </script></body></html>

(113)

Step 4:

(114)

<!DOCTYPE html><html><body> <p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }); }; // end of plugin })(jQuery); $(‘p’).notHate().hide(); </script></body></html>

(115)

<!DOCTYPE html><html><body> <p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script>

(function ($) {

$.fn.notHate = function () {

return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ‘love’) ); }); }; // end of plugin })(jQuery); $(‘p’).notHate().hide(); </script></body></html>

this == jQuery

(116)

<!DOCTYPE html><html><body> <p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { return this.each(function () { $(this).text(

$(this).text().replace(/hate/g, ‘love’) ); }); }; // end of plugin })(jQuery); $(‘p’).notHate().hide(); </script></body></html>

this == DOM element

(117)

Step 5:

(118)

<!DOCTYPE html><html><body> <p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ $.fn.notHate.defaults.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery); $(‘p’).notHate(); </script></body></html>

(119)

Step 6:

(120)

<!DOCTYPE html><html><body> <p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script> (function ($) { $.fn.notHate = function () { return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ $.fn.notHate.defaults.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery);

$(‘p’).notHate({text: ‘love-love-love’}); </script></body></html>

(121)

<!DOCTYPE html><html><body> <p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script>

(function ($) {

$.fn.notHate = function (options) { return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ $.fn.notHate.defaults.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery);

$(‘p’).notHate({text: ‘love-love-love’}); </script></body></html>

(122)

<!DOCTYPE html><html><body> <p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script>

(function ($) {

$.fn.notHate = function (options) {

var settings = $.extend({},

➥ $.fn.notHate.defaults, options); return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ $.fn.notHate.defaults.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery);

$(‘p’).notHate({text: ‘love-love-love’}); </script></body></html>

(123)

<!DOCTYPE html><html><body> <p>I hate jQuery!</p>

<p>I mean really hate jQuery!</p> <script src=”jquery.js”></script> <script>

(function ($) {

$.fn.notHate = function (options) {

var settings = $.extend({},

➥ $.fn.notHate.defaults, options); return this.each(function () { $(this).text( $(this).text().replace(/hate/g, ➥ settings.text) ); }); }; // end of plugin $.fn.notHate.defaults = {text:‘love’}; })(jQuery);

$(‘p’).notHate({text: ‘love-love-love’}); </script></body></html>

(124)
(125)

News

Four conferences next year:

London, Boston, San Francisco and online

New plugin site

jQuery Forum (moving from Google Groups)

(126)
(127)

Remy Sharp

@rem

jQuery team member

Co-author of O'Reilly

jQuery Cookbook

(due November 20th)

jqueryfordesigners.com

remysharp.com

(128)

Remy Sharp

@rem

jQuery team member

Co-author of O'Reilly

jQuery Cookbook

(due November 20th)

jqueryfordesigners.com

remysharp.com

?

Questions

References

Related documents

Check insulation resistance to ground on all generator windings, including the main rotating assembly, the main stator assembly, the exciter fi eld and armature assemblies, and

We also consider strong double graph and strong p-fold graph to construct some new families of graphs G for which E(G) &gt; LE(G).. Keywords: Spectra of graph, energy, Laplacian

Pdf viewer with pdf then download jquery ui documentation pdf server using it with simple text box in order to move elements that this method during your application. Why does rust

Simply Buttons, version 2.0 Simply Buttons, version 2.0 jCrumb jquery 1.0 jCrumb jquery 1.0 jQuery Alpha Numeric jQuery Alpha Numeric

jQuery Datatables 1.7.x jQuery Datatables 1.7.x jQuery Form 2.6.x jQuery Form 2.6.x jQuery Gradient 1.0 jQuery Gradient 1.0 jQuery Livequery 1.x jQuery Livequery 1.x jQuery

• JQuery HTML o JQuery Get o JQuery Set o JQuery Add o JQuery Remove o JQuery CSS Classes o JQuery css() o JQuery Dimensions • JQuery Traversing o JQuery Traversing o

Experienced: LAMP, Zend Framework, Yii, Bootstrap, jQuery, jQuery UI, jQuery Mobile, AWS Management, Javascript, AngularJS,SQL (MYSQL), NoSQL, Rest Services, API Integrations

With parameter PERNR selected, select “Assign Result Detail Type.” We want to show an employee header with generic information on the employee, a generic overview, and – for this