yearning jquery

181
Yearning jQuery

Upload: remy-sharp

Post on 01-Sep-2014

3.420 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Yearning jQuery

Yearning jQuery

Page 2: Yearning jQuery

Hi, I’m Remy / @rem

Screencast @ jqueryfordesigners.com

Questions: interrupt me & ask!

Page 3: Yearning jQuery
Page 4: Yearning jQuery

1. Build without jQuery.

2. Design the start and end of your effects without jQuery.

3. Add jQuery a little at a time.

Page 5: Yearning jQuery

"all about CSS"(a lot of it is...)

- Me, to many a colleague

Page 6: Yearning jQuery

Dear designer/dev: if you're using JavaScript to do a job that CSS could have done perfectly well, you've lost some points in my book. Sorry

@remRemy Sharp

Page 7: Yearning jQuery

The day someone loses business because an animated transition wasn't used to reveal a screenshot: I'll sell my left nut on eBay. #cssinstead

@remRemy Sharp

Page 8: Yearning jQuery

What we're covering

• Getting friendly with the $

• DOM navigation & manipulation

• Events

• Ajax

• Tips

Page 9: Yearning jQuery

APIsdocs.jquery.comapi.jquery.com

visualjquery.com

Blogs, tutorials, screencasts,plugins, development sprints

forum.jquery.com

IRC channelirc.freenode.net/#jquery

Twitter@jquery

@jquerysites@jqueryui

Help!

Page 10: Yearning jQuery

jsbin.com

Page 11: Yearning jQuery

Bling Function

Page 12: Yearning jQuery
Page 13: Yearning jQuery

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';

}

}

}

Page 14: Yearning jQuery

jQuery simplifies

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

Page 15: Yearning jQuery

jQuery simplifies

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

jQuery function

Page 16: Yearning jQuery

jQuery simplifies

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

jQuery function

CSS expression

Page 17: Yearning jQuery

jQuery simplifies

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

jQuery function

CSS expression

jQuery method

Page 18: Yearning jQuery

jQuery simplifies

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

Page 19: Yearning jQuery

$('just css')

Page 20: Yearning jQuery

Tools of the Trade

Page 21: Yearning jQuery

• Firefox: Firebug (& FireQuery*)

• Safari & Chrome: Web Inspector

• Opera: DragonFly

• IE: Web Developer Toolbar

Page 22: Yearning jQuery
Page 23: Yearning jQuery
Page 24: Yearning jQuery
Page 25: Yearning jQuery

$.fn.jquery

Tip

(little 'q')

Page 26: Yearning jQuery

Let's play.

http://twitter.com

Page 27: Yearning jQuery

jQuery on every site?

No Problem.

Page 28: Yearning jQuery

http://bit.ly/9JAcCj

Page 29: Yearning jQuery

Let's play.

Page 30: Yearning jQuery

Installing jQuery

Page 31: Yearning jQuery

dev or min?

Page 32: Yearning jQuery

Hosting options• Host it yourself (good for offline

dev)

• Hotlink it:

• Media Temple

• Microsoft

• Google (my pick)http://docs.jquery.com/Downloading_jQuery

Page 33: Yearning jQuery

CDN FTW

Page 34: Yearning jQuery

Tip: keep a copy on your machine

Page 35: Yearning jQuery

Where does it all go?

Page 36: Yearning jQuery

• jQuery first

• Then jQuery plugins

• Then your code

Page 37: Yearning jQuery

• Other JavaScript libraries

• jQuery last library

• Then jQuery plugin scripts

• Then your code

Page 38: Yearning jQuery

<html><head> <styles> <!-- make me beautiful --> </styles></head><body> <content> <!-- make me learned --> </content> <behaviour> <!-- ooo, matron --> </behaviour></body></html>

Page 39: Yearning jQuery

<html><head> <styles> <!-- make me beautiful --> </styles></head><body> <content> <!-- make me learned --> </content> <behaviour> <!-- ooo, matron --> </behaviour></body></html>

Styles first let's the page

render without scripts

blocking

Page 40: Yearning jQuery

<html><head> <styles> <!-- make me beautiful --> </styles></head><body> <content> <!-- make me learned --> </content> <behaviour> <!-- ooo, matron --> </behaviour></body></html>

Then your content,

again so that it's delivered

to your visitor as early as possible

Page 41: Yearning jQuery

<html><head> <styles> <!-- make me beautiful --> </styles></head><body> <content> <!-- make me learned --> </content> <behaviour> <!-- ooo, matron --> </behaviour></body></html>

Finally, add your

behaviour, the jQuery

and sexy magic jazz.

Page 42: Yearning jQuery

$(document).ready(function () {

// < YOU >

});

Page 43: Yearning jQuery

$(document).ready(function () {

// < YOU >

});

Page 44: Yearning jQuery

$(function () {

// < YOU >

});

Page 45: Yearning jQuery

jQuery(function ($) {

// < YOU >

});

Tip

Useful when giving code to a client

Page 46: Yearning jQuery

<!DOCTYPE html><html lang="en"><head><meta charset=utf-8 /><title>My first jQuery page</title></head><body><h1>Remy woz 'ere</h1><p>Lorem ipsum dolor sit amet.</p><script src="jquery.min.js"></script><script>$(function () { // < YOU >});</script></body></html>

Page 47: Yearning jQuery

Is it jQuery or $?

Page 48: Yearning jQuery

It's both.

Page 49: Yearning jQuery

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

Page 50: Yearning jQuery

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

Page 51: Yearning jQuery

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

Page 52: Yearning jQuery

∞∞∞ Chaining ∞∞∞

Page 53: Yearning jQuery

$('div').show().hide().slideUp().slideDown();

Page 54: Yearning jQuery

$('div').show().hide().slideUp().slideDown();

Get the divs,

Page 55: Yearning jQuery

$('div').show().hide().slideUp().slideDown();

and show them,

Page 56: Yearning jQuery

$('div').show().hide().slideUp().slideDown();

now hide them,

Page 57: Yearning jQuery

$('div').show().hide().slideUp().slideDown();

and then slide them up,

Page 58: Yearning jQuery

$('div').show().hide().slideUp().slideDown();

then finally slide them down.

Page 59: Yearning jQuery

Can't chain text getters

.val() .html() .text() .css(prop) .attr(prop), etc

Page 60: Yearning jQuery

if ( $('foo') ) { doAmazing();}

Gotcha & Tip

Page 61: Yearning jQuery

1) $('foo')

2) $()

3) []

4) [].join(',') // works

Page 62: Yearning jQuery

if ( $('foo') ) { doAmazing();}

Page 63: Yearning jQuery

if ( $('foo').length ) { doAmazing();}

Page 64: Yearning jQuery

$('el').doStuffvs

$.doStuff

Page 65: Yearning jQuery

$('el').doStuffruns against everything

matched.

Page 66: Yearning jQuery

$.doStuffis a utility.

Page 67: Yearning jQuery

$.browser.version$.browser.msie$.browser.safari $.browser.webkit

Deprecated

Page 68: Yearning jQuery

Doing stuff

Page 69: Yearning jQuery

$('a').click(function () { alert('I got clicked'); return false;});

Page 70: Yearning jQuery

$('a').click(function () { alert('I got clicked'); return false;});

Find the anchors

Page 71: Yearning jQuery

$('a').click(function () { alert('I got clicked'); return false;});

when they're clicked

Page 72: Yearning jQuery

$('a').click(function () { alert('I got clicked'); return false;});

run this function - don't worryabout the crazy syntax.

Page 73: Yearning jQuery

$('a').click(function () { alert('I got clicked'); return false;});

Cancel the browser's default action, which is to redirect.

Page 74: Yearning jQuery

$('a').click(function(event){ event.preventDefault(); alert('I got clicked');});

Same thing as cancelling (almost), this is useful for debugging.

Page 75: Yearning jQuery

• click, dblclick

• mousedown, mouseup, mousemove mouseover, mouseout, mouseenter mouseleave

• keydown, keypress, keyup

• submit, change, blur, focus, select

• scroll, resize, load, error

Page 76: Yearning jQuery

Tabs freakin' everywhere!

Page 77: Yearning jQuery
Page 78: Yearning jQuery
Page 79: Yearning jQuery
Page 80: Yearning jQuery
Page 81: Yearning jQuery

You get the idea.

Page 82: Yearning jQuery

• A group of "panels"

• Tabs (or links) pointing to a panel

• Clicking tab, hides all panels, then shows just one

A tabbing system is...

Page 83: Yearning jQuery

...the content can also be be Ajaxy

Page 84: Yearning jQuery

A few words on this

Page 85: Yearning jQuery

this is the element

that the event is

happening to.

Page 86: Yearning jQuery

$('a').click(function () { console.log(this);});

this is the anchor element, not the jQuery wrapped element.

Page 87: Yearning jQuery

$('a').click(function () { setTimeout(function () { $(this).text("I'm alive!"); }, 1000);});

Common mistake

Page 88: Yearning jQuery

$('a').click(function () { setTimeout(function () { $(this).text("I'm alive!"); }, 1000);});

Common mistake

this is the window object, not the link

Page 89: Yearning jQuery

$('a').click(function () { var el = this; setTimeout(function () { $(el).text("I'm alive!"); }, 1000);});

Common mistake

Page 90: Yearning jQuery

Live codin' time!

tabs.html

Page 91: Yearning jQuery

Events

Page 92: Yearning jQuery

$('input').keydown(function (event) { // what's the event arg?});

Page 93: Yearning jQuery

•.keyup(fn), .click(fn), etc

•.bind(type, fn)

•.trigger(type), unbind(type)

•.one(type, fn)

Page 94: Yearning jQuery

Clickables

Tip

Page 95: Yearning jQuery

$.event.special.click = { setup: function() { $(this).css('cursor','pointer'); return false; }, teardown: function() { $(this).css('cursor',''); return false; }};

All credit to David Walsh

Page 96: Yearning jQuery

Problem

Page 97: Yearning jQuery

<h1>Super Ted</h1><img src="superted.jpg"><img src="spotty.jpg"><img src="txspete.jpg"><script src="jquery.js"><script>$('img').click(function(){ showDetails(this);});</script>

When the page has finished

loading, the jQuery runs

Page 98: Yearning jQuery

<h1>Super Ted</h1><img src="superted.jpg"><img src="spotty.jpg"><img src="txspete.jpg"><script src="jquery.js"><script>$('img').click(function(){ showDetails(this);});</script>

Clicking these images

"shows details"

Page 99: Yearning jQuery

<h1>Super Ted</h1><img src="superted.jpg"><img src="spotty.jpg"><img src="txspete.jpg"><script src="jquery.js"><script>$('img').click(function(){ showDetails(this);});</script>

Now Ajax (or something else) add new images to the

page

Page 100: Yearning jQuery

<h1>Super Ted</h1><img src="superted.jpg"><img src="spotty.jpg"><img src="txspete.jpg"><img src="mothernature.jpg"><script src="jquery.js"><script>$('img').click(function(){ showDetails(this);});</script>

Now Ajax (or something else) add new images to the

page

Page 101: Yearning jQuery

<h1>Super Ted</h1><img src="superted.jpg"><img src="spotty.jpg"><img src="txspete.jpg"><img src="mothernature.jpg"><script src="jquery.js"><script>$('img').click(function(){ showDetails(this);});</script>

Clicking this image doesn't do anything.

Page 102: Yearning jQuery

Solution: delegation

Page 103: Yearning jQuery

<h1>Super Ted</h1><img src="superted.jpg"><img src="spotty.jpg"><img src="txspete.jpg"><script src="jquery.js"><script>$('#superTed').delegate('img','click',function(){ showDetails(this);});</script>

Page 104: Yearning jQuery
Page 105: Yearning jQuery

These images are loaded after

the DOM has loaded via Ajax

Page 106: Yearning jQuery

We're going to "delegate" the task of listening for particular

events to this <div>

Page 107: Yearning jQuery

We've "delegate" clicks, looking for the "img" selector

Page 108: Yearning jQuery

$('div').delegate('img','click',function(){ /* do funky stuff */ });

Page 109: Yearning jQuery

Now, any new images inserted in this <div> can be clicked and will fire the

"funky stuff" function

Page 110: Yearning jQuery

Ajax Warning: wear your tech-hat

Page 111: Yearning jQuery

No brainer Ajax

Page 112: Yearning jQuery

.load

Page 113: Yearning jQuery
Page 114: Yearning jQuery

Example

Page 115: Yearning jQuery

$('#detail').load('page.html');

Page 116: Yearning jQuery

$('#detail').load('page.html #id');

Page 117: Yearning jQuery

1. Ajax load the page

2. Search for the selector passed (#dizzy)

3. Squirt contents found into original selector

Page 118: Yearning jQuery

$('#tabs a').click(function (event) { // this.pathname = 'ajax-load-detail.html' $('#detail').load(this.pathname); return false;});

Page 119: Yearning jQuery

$('#tabs a').click(function (event) { $('#detail').load(this.pathname + ' ' + this.hash); return false;});

this.hash

Page 120: Yearning jQuery

JSON

Page 121: Yearning jQuery

{ screen_name : "@rem", height : "short", fingers : 5, brit : true}

JavaScript Object

Page 122: Yearning jQuery

{ "screen_name": "@rem", "height": "short", "fingers": 5, "brit": true}

JSON

Page 123: Yearning jQuery

JSONP WTF

Page 124: Yearning jQuery

{ "screen_name": "@rem", "height": "short", "fingers": 5, "brit": true}

JSON+...

Page 125: Yearning jQuery

callback({ "screen_name": "@rem", "height": "short", "fingers": 5, "brit": true});

JSON+Padding

Page 126: Yearning jQuery

Getting other people's data

Page 127: Yearning jQuery

$.getJSON

Page 128: Yearning jQuery

Remember =?

Page 129: Yearning jQuery

Twitter

ajax/twitter.html

Page 130: Yearning jQuery

$(document).ready(function () { $.getJSON('http://twitter.com/statuses/user_timeline/rem.json?callback=?', function (data) { $('#tweets').empty();

$.each(data, function (i, item) { $('#tweets').append('<li class="tweet">' + item.text + '</li>'); }); });});

Page 131: Yearning jQuery

Giving users feedback

Loading...

Page 132: Yearning jQuery

Ajax order

1. ajaxStart

2. ajaxSuccess (or ajaxError)

3. ajaxComplete

http://api.jquery.com/?s=ajax

Page 133: Yearning jQuery

$('#status').ajaxStart(function () { $(this).fadeIn();}).ajaxComplete(function () { $(this).fadeOut();});

Page 134: Yearning jQuery

Deferreds

Page 135: Yearning jQuery

$.get('foo.html', function (html) { $('#latest').append(html);});

var jqXHR = $.get('foo.html');

jqXHR.done(function (html) { $('#latest').append(html);});

Page 136: Yearning jQuery

$.ajax({ url: 'foo.json', dataType: 'json', success: function () { // this === xhr }, error: function () { }});

Page 137: Yearning jQuery

$.ajax({ url: 'foo.json', dataType: 'json', context: document.body, success: function () { // this === body element }, error: function () { }});

Page 138: Yearning jQuery

var jqXHR = $.ajax({ url: 'foo.json', dataType: 'json', context: document.body});

jqXHR.then(success, fail);

Page 139: Yearning jQuery

var jqXHR = $.ajax({ url: 'foo.json', dataType: 'json', context: document.body});

jqXHR.then(success, fail);

// much later in the code

jqXHR.done(success2);

Page 140: Yearning jQuery

jqXHR is a promise

Page 141: Yearning jQuery
Page 142: Yearning jQuery
Page 143: Yearning jQuery

var jqXHR = $.ajax({ url: 'foo.json', dataType: 'json', context: document.body});

// much later in the code

jqXHR.done(success);

Page 144: Yearning jQuery

.done(ok) // success

.fail(fail) // error

.always(fn) // complete

.then(ok, fail)

Page 145: Yearning jQuery

Plugins

Page 146: Yearning jQuery

What’s a plugin?A plugin is nothing more than a custom jQuery method created to extend the functionality of the jQuery object

$(‘ul’).myPlugin()

Page 147: Yearning jQuery

Plugin design in 6 steps

Page 148: Yearning jQuery

Step 1:

create a private scope for $ alias

Page 149: Yearning jQuery

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

})(jQuery);</script></body></html>

Page 150: Yearning jQuery

Step 2:

attach plugin to fn alias (aka prototype)

Page 151: Yearning jQuery

<!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>

Page 152: Yearning jQuery

<!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>

Page 153: Yearning jQuery

Step 3:

add implicit iteration

Page 154: Yearning jQuery

<!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>

Page 155: Yearning jQuery

Step 4:

enable chaining

Page 156: Yearning jQuery

<!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>

Page 157: Yearning jQuery

<!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

Page 158: Yearning jQuery

<!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

this == jQuery

Page 159: Yearning jQuery

Step 5:

add default options

Page 160: Yearning jQuery

<!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>

Page 161: Yearning jQuery

Step 6:

add custom options

Page 162: Yearning jQuery

<!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>

Page 163: Yearning jQuery

<!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>

Page 164: Yearning jQuery

<!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>

Page 165: Yearning jQuery

<!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>

http://jsbin.com/ifuga/edit

Page 166: Yearning jQuery
Page 167: Yearning jQuery

<!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>

Page 168: Yearning jQuery

<!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.text(function (i, text) { return text.replace(/hate/g, ➥ settings.text); });}; // end of plugin$.fn.notHate.defaults = {text:‘love’};})(jQuery);

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

Page 169: Yearning jQuery

Poorly designed plugins

Page 170: Yearning jQuery

$.fn.myplugin = function () {  var me = $(this).each(function() {    return $(this).bind('someEvent', function () {      // does something    });  });

  return me;};

Page 171: Yearning jQuery

$.fn.myplugin = function () {  var me = $(this).each(fn);

  return me;};

Page 172: Yearning jQuery

$.fn.myplugin = function () {  return $(this).each(fn);};

Page 173: Yearning jQuery

$.fn.myplugin = function () {  return $(this).each(function() {    return $(this).bind('someEvent', function () {      // does something    });  });};

Page 174: Yearning jQuery

$.fn.myplugin = function () {  return $(this).each(function() {    return $(this).bind('someEvent', function () {      // does something    });  });};

Page 175: Yearning jQuery

$.fn.myplugin = function () {  return this.each(function() {    return $(this).bind('someEvent', function () {      // does something    });  });};

Page 176: Yearning jQuery

$.fn.myplugin = function () {  return this.each(function() {    return $(this).bind('someEvent', function () {      // does something    });  });};

Page 177: Yearning jQuery

$.fn.myplugin = function () {  return this.each(function() {    $(this).bind('someEvent', function () {      // does something    });  });};

Page 178: Yearning jQuery

$.fn.myplugin = function () {  return this.each(function() {    $(this).bind('someEvent', function () {      // does something    });  });};

Page 179: Yearning jQuery

$.fn.myplugin = function () { return this.bind('someEvent', function () {  // does something  });};

Page 180: Yearning jQuery

(function ($) { $.fn.myplugin = function () {   return this.bind('someEvent', function () {    // does something  }); };})(jQuery);

Page 181: Yearning jQuery

Questions?To contact me after my presentation – text NHT to INTRO (46876)

Or [email protected]@rem