Created
June 9, 2017 21:58
-
-
Save kirsten/18792af6f2da0605a2f0402810d106de to your computer and use it in GitHub Desktop.
Exported from Popcode. Click to import: https://popcode.org/?gist=18792af6f2da0605a2f0402810d106de
This file contains 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(column, row, 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 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 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(col, row, color) { | |
var cell = $('#t')[0].rows[row].cells[col]; | |
cell.style.backgroundColor = color; | |
} | |
// Write your code below this line |
This file contains 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; | |
margin: 10px 0; | |
} | |
#t td { | |
border: 1px solid blue; | |
width: 2em; | |
height: 2em; | |
} | |
.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; | |
margin: 10px 0; | |
padding: 3px; | |
padding-left: 1em; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment