diff --git a/blink.js b/blink.js index cd23806..89ee575 100644 --- a/blink.js +++ b/blink.js @@ -1 +1,38 @@ -// YOUR CODE GOES HERE +// Write a jQuery plugin that makes an element act like a tag. +// It should work for any arbitrary speed. + +// V2 +// Make plugin work for selectors that correspond to multiple elements. + +(function ( $ ) { + + $.fn.blink = function(duration) { + return this.each(function() { + setInterval(blinkit,duration,$(this)); + }); + }; + +}( jQuery )); + +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 79532f5..16075e8 100644 --- a/index.html +++ b/index.html @@ -13,8 +13,10 @@ I'm also a blink tag!