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
| $(function(){ | |
| $("#add").click(function(){ | |
| var description=$("#description").val(); | |
| if(description === ""){ | |
| $("#alert").html("<strong>Warning</strong> You left the todo app!"); | |
| $("#alert").fadeIn().delay(1000).fadeOut(); | |
| return false; | |
| } | |
| $("#todos").prepend("<li><input type='checkbox' name='checkbox'>"+ description+ "</li>"); | |
| $("#form")[0].reset(); |
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
| var KEY={ | |
| UP: 38, | |
| DOWN: 40, | |
| W: 87, | |
| S: 83, | |
| }; | |
| var pingpong = {}; | |
| pingpong.ball = { | |
| speed: 5, | |
| x: 150, |
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
| function loadasync(url){ | |
| var head=document.getElementsByTagName("head")[0]; | |
| var script=document.createElement("script"); | |
| script.src=url; | |
| head.appendChild(script); | |
| } | |
| function urlArg(){ | |
| var args = {}; | |
| var query = window.location.search.substring(1); |
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
| <html> | |
| <head><!--html--> | |
| <title>example1</title> | |
| <link rel="stylesheet" type="text/css" href="do.css"> | |
| </head> | |
| <body> | |
| <div id="point"></div> | |
| <div id="question"></div> | |
| <form name="radioAnswers"> |
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
| For example, take a look at the first example below: | |
| 1)(function(){ | |
| var cart={ | |
| item: "product1", | |
| price: 35.50, | |
| quantity: 2, | |
| buying: function(){ | |
| alert("you bought"+this.item); | |
| } | |
| }; |
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
| var allQuestions = []; | |
| allQuestions[0]={ | |
| question: "what is your name?", | |
| choices:["steve", "kevin", "chloe","haeseong"], | |
| correctAnswer: 1 | |
| }; | |
| allQuestions[1]={ | |
| question: "what is your passion?", | |
| choices:["programmer", "teacher", "scientist","home builder"], | |
| correctAnswer: 1 |
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
| $(document).ready(function () { | |
| $(".section").click(checkForCode); | |
| function getRandom(n) { | |
| return Math.floor(Math.random() * n); | |
| } | |
| var hideCode = function () { | |
| var num = getRandom(4); | |
| $(".section").each(function (index, value) { | |
| if (num == index) { |
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
| $(document).ready(function(){ | |
| $("#move_up").click(function(){ | |
| $("#change_me").animate({top:100}, 1000); | |
| }); | |
| $("#move_down").click(function(){ | |
| $("#change_me").animate({top:400},1000) | |
| }); | |
| $("#change_color").click(function(){ | |
| $("#change_me").css("background-color","purple"); | |
| }); |
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
| To set attributes of a property or to create a new property with the specified attributes. | |
| var a = {}; | |
| Object.defineProperty(0, "x", {value:1, writable: true, enumerable:false, configurable: true}); | |
| Guess what this does? | |
| Also changing this (data property to an accessor property) => | |
| Object.defineProperty(0, "x", { get: function(){ return 0} }); |
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
| write a map and forEach function: | |
| function forEach(array, action){ | |
| for (var i =0; i < array.length; i++){ | |
| action(array[i])); | |
| } | |
| }; | |
| function map(func,array){ | |
| var result =[]; |