Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Solutions for http://tutorialzine.com/2014/05/javascript-challenge-make-me-blue/#comment-154928 */
- /* By Victor Schröder - linkedin.com/in/schrodervictor/ */
- //1. IDs are easy
- $('#me').blue();
- //2. So are classes..
- $('.wants-to-be-blue').blue();
- //3. The unordered list
- $('ul li:nth-child(4)').blue();
- //4. Treacherous HTML ahead!
- $('#make-me-blue, ' +
- 'section:first div:nth-of-type(3), ' +
- 'section:last p:first > span, ' +
- 'section:last p:nth-of-type(3) > span > i:nth-of-type(2), ' +
- 'section:last > div > div').blue();
- // 5. Mind the order!
- for (i=1;i<=9;i++) {
- $('div:contains("' + i + '")').blue();
- }
- // 6. Beware of the bombs!
- $('div:not(".bomb")').blue();
- // 7. You’ve got enemies!
- setTimeout(function() {
- $('section div').blue();
- }, 1100);
- //8. Speed is everything
- $('button').trigger('click');
- $('div').blue();
- //9. Randomization
- $('#' + $('#map').text().split(' ').join(',#')).blue();
- //10. Boss fight
- var delay = 60,
- position = 0,
- divs = $('div');
- setTimeout(makeBlue, delay);
- function makeBlue(){
- divs.eq(position).blue();
- divs.eq(position + 5).blue();
- setTimeout(function(){
- position++;
- if(position >= divs.length){
- position = 0;
- }
- setTimeout(makeBlue, 500);
- }, 100);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement