From 785f1250363798185f78d5c44e0d5c51f5df75c9 Mon Sep 17 00:00:00 2001 From: bluemittens505 Date: Sun, 7 Feb 2016 22:24:40 -0500 Subject: [PATCH 1/3] Initial version of V1 --- blink.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/blink.js b/blink.js index cd23806..9697961 100644 --- a/blink.js +++ b/blink.js @@ -1 +1,14 @@ -// YOUR CODE GOES HERE +// Write a jQuery plugin that makes an element act like a tag. +// It should work for any arbitrary speed. + +// V1 +// Make plugin work for selectors that correspond to a single element. + +$.fn.blink = function() { + setInterval(blinkit,1000,this); +}; + +function blinkit(obj) { + var value = obj.css('visibility') === 'visible' ? 'hidden' : 'visible'; + obj.css('visibility',value); +} From 63b48d6f5108ef20e5fbb74f16ec8d7f3691653b Mon Sep 17 00:00:00 2001 From: bluemittens505 Date: Mon, 8 Feb 2016 20:59:11 -0500 Subject: [PATCH 2/3] V1 Make plugin work for selectors that correspond to a single element --- blink.js | 11 ++++++++--- index.html | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/blink.js b/blink.js index 9697961..93e8ddf 100644 --- a/blink.js +++ b/blink.js @@ -4,9 +4,14 @@ // V1 // Make plugin work for selectors that correspond to a single element. -$.fn.blink = function() { - setInterval(blinkit,1000,this); -}; +(function ( $ ) { + + $.fn.blink = function(duration) { + setInterval(blinkit,duration,this); + return this; + }; + +}( jQuery )); function blinkit(obj) { var value = obj.css('visibility') === 'visible' ? 'hidden' : 'visible'; diff --git a/index.html b/index.html index 79532f5..3114130 100644 --- a/index.html +++ b/index.html @@ -13,8 +13,9 @@ I'm also a blink tag! From 46444e1444d44c8f6f59831363ebab502973d079 Mon Sep 17 00:00:00 2001 From: bluemittens505 Date: Mon, 8 Feb 2016 21:24:53 -0500 Subject: [PATCH 3/3] V2 Make plugin work for selectors that correspond to multiple elements. --- blink.js | 27 +++++++++++++++++++++++---- index.html | 5 +++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/blink.js b/blink.js index 93e8ddf..89ee575 100644 --- a/blink.js +++ b/blink.js @@ -1,14 +1,15 @@ // Write a jQuery plugin that makes an element act like a tag. // It should work for any arbitrary speed. -// V1 -// Make plugin work for selectors that correspond to a single element. +// V2 +// Make plugin work for selectors that correspond to multiple elements. (function ( $ ) { $.fn.blink = function(duration) { - setInterval(blinkit,duration,this); - return this; + return this.each(function() { + setInterval(blinkit,duration,$(this)); + }); }; }( jQuery )); @@ -17,3 +18,21 @@ function blinkit(obj) { var value = obj.css('visibility') === 'visible' ? 'hidden' : 'visible'; obj.css('visibility',value); } + + +// V1 +// Make plugin work for selectors that correspond to a single element. + +// (function ( $ ) { + +// $.fn.blink = function(duration) { +// setInterval(blinkit,duration,this); +// return this; +// }; + +// }( jQuery )); + +// function blinkit(obj) { +// var value = obj.css('visibility') === 'visible' ? 'hidden' : 'visible'; +// obj.css('visibility',value); +// } diff --git a/index.html b/index.html index 3114130..16075e8 100644 --- a/index.html +++ b/index.html @@ -14,8 +14,9 @@