Created
February 4, 2017 20:17
-
-
Save alexpelan/34aa55e9f8486e918dc6f3e1c19f925d to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=34aa55e9f8486e918dc6f3e1c19f925d
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> | |
| <head> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script> | |
| <meta charset="utf-8" /> | |
| <script> | |
| </script> | |
| <title>JS-Grid We Do</title> | |
| </head> | |
| <body> | |
| <h2>Fun on a grid</h2> | |
| <div class="intro">You get a function: | |
| <div class="code"> | |
| setColor(row, column, color); | |
| </div> | |
| For a given row and column (both numbered from 0), it colors the corresponding cell. | |
| <br> | |
| <strong>Directions:</strong> type | |
| <span class="code"> | |
| setColor(2, 0, "purple"); | |
| </span> | |
| on line 6 of JavaScript | |
| </div> | |
| <table id="t"> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| <tr><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td></tr> | |
| </table> | |
| </body> | |
| </html> |
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
| {"enabledLibraries":["jquery"]} |
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 setColor(row, col, color) { | |
| var cell = $('#t')[0].rows[row].cells[col]; | |
| cell.style.backgroundColor = color; | |
| } | |
| // Write your code below this line | |
| var color = "blue"; | |
| setColor(2, 0, color); | |
| setColor(8, 3, color); | |
| setColor(5, 4, color); |
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
| #t { | |
| border-collapse: collapse; | |
| } | |
| #t td { | |
| border: 1px solid blue; | |
| width: 1em; | |
| height: 1em; | |
| } | |
| .intro { | |
| font-family: arial; | |
| line-height: 1.5em; | |
| margin-bottom: 1em; | |
| } | |
| .code { | |
| color: green; | |
| font-family: monospace; | |
| font-weight: bold; | |
| } | |
| div.code { | |
| border: 1px solid green; | |
| padding: 3px; | |
| padding-left: 1em; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment