This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const myCustomDiv = document.createElement('div'); | |
| function respondToTheClick(evt) { | |
| console.log('A paragraph was clicked: ' + evt.target.textContent); | |
| } | |
| for (let i = 1; i <= 200; i++) { | |
| const newElement = document.createElement('p'); | |
| newElement.textContent = 'This is paragraph number ' + i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title></title> | |
| <style type="text/css"> | |
| @import url(https://fonts.googleapis.com/css?family=Roboto); | |
| html, body { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <title>Mostly Fluid - Quiz</title> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <style type="text/css"> | |
| /* | |
| These are the default styles. No need to change these. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <title>Mostly Fluid - Quiz</title> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <style type="text/css"> | |
| /* | |
| These are the default styles. No need to change these. | |
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //5.8 Animate I, 5.9 Animate II, 5.10 Animation Speed, 5.11 Animate III | |
| $(document).ready(function() { | |
| $('.tour').on('mouseenter', function() { | |
| $(this).addClass('highlight'); | |
| $(this).find('.per-night').animate({'top': '-14px', 'opacity': '1'}, 'fast'); //adding one more key/value to this object representing a top of -14px | |
| }); | |
| $('.tour').on('mouseleave', function() { | |
| $(this).removeClass('highlight'); | |
| $(this).find('.per-night').animate({'top': '0px', 'opacity': '0'}, 'fast'); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //5.3 CSS I, 5.4 CSS II, 5.5 Show Photo, 5.6 Refactoring to CSS | |
| $(document).ready(function() { | |
| $('.tour').on('mouseenter', function() { | |
| $(this).addClass('highlight'); //We've extracted out our styles into a new CSS class called highlight. | |
| $(this).find('.photos').show(); | |
| }); | |
| $('.tour').on('mouseleave', function() { | |
| $(this).removeClass('highlight'); | |
| }); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //4.18 Link Events I, 4.19 Link Events II | |
| // 4.20 Event Parameter I, 4.21 Event Parameter II | |
| $(document).ready(function() { | |
| $('.see-photos').on('click', function(event) { | |
| event.stopPropagation(); //use that event to stop the second event handler from being called | |
| event.preventDefault(); //prevent the browser from jumping to the top of the page when the link is clicked | |
| $(this).closest('.tour').find('.photos').slideToggle(); | |
| }); | |
| $('.tour').on('click', function() { | |
| alert('This event handler should not be called.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //chapt4.13 Keyup Event, 4.14 Keyup Event Handler I, | |
| // 4.15 Keyup Event Handler II, 4.16 Another Event Handler | |
| $(document).ready(function() { | |
| $('#nights').on('keyup', function() { | |
| var nights = +$(this).val(); | |
| var dailyPrice = +$(this).closest('.tour').data('daily-price'); | |
| $('#total').text(nights * dailyPrice); | |
| $('#nights-count').text($(this).val()); | |
| }); | |
| $('#nights').on('focus', function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //chapt4.8 Mouseover I, 4.9 Mouseover II, 4.10 Mouseleave, 4.11 Named Functions | |
| $(document).ready(function() { | |
| $('#tour').on('click', 'button', function() { | |
| $('.photos').slideToggle(); | |
| }); | |
| function showPhotos() { | |
| $(this).find('span').slideToggle(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Given a year, return the century it is in. The first century spans from the year 1 | |
| // up to and including the year 100, the second - from the year 101 up to | |
| // and including the year 200, etc. | |
| int centuryFromYear(int year) { | |
| double century; //typecasting year to double precision | |
| century = (double)year / 100; // and divide it by 100 | |
| century = Math.ceil(century);// and get the ceiling of it | |
| return (int)century; | |
| } |