Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Blink Homework #52

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion blink.js
Original file line number Diff line number Diff line change
@@ -1 +1,38 @@
// YOUR CODE GOES HERE
// Write a jQuery plugin that makes an element act like a <blink> 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';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be super clear, I would name this variable newValue.

obj.css('visibility',value);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably put this after line 7 so that you aren't creating any global variables/functions.



// 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);
// }
6 changes: 4 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
I'm <em>also</em> a <code>blink</code> tag!
</div>
<script>
$('.myDiv').blink(1000);
// $('.otherDiv').blink(500);
//$('.myDiv').blink(1000);
//$('.myDiv').blink(1000).css("color","red");
//$('.otherDiv').blink(500);
$('div').blink(700);
</script>
</body>
</html>