Skip to content

Instantly share code, notes, and snippets.

@spudtrooper
Last active February 18, 2022 12:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spudtrooper/ec86cc9c6c11ffe5f28db1173292e182 to your computer and use it in GitHub Desktop.
Save spudtrooper/ec86cc9c6c11ffe5f28db1173292e182 to your computer and use it in GitHub Desktop.
<html>
<head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>
<table id="tab" border=0></table>
<script>
const black = 'https://abs-0.twimg.com/emoji/v2/svg/2b1c.svg';
const yellow = 'https://abs-0.twimg.com/emoji/v2/svg/1f7e8.svg';
const green = 'https://abs-0.twimg.com/emoji/v2/svg/1f7e9.svg';
const colors = [
black,
yellow,
green,
];
const numRows = 25;
let main = () => {
for (let i=0; i<numRows; i++) {
let tr = $('<tr>');
for (let j=0; j<5; j++) {
let col = colors[Math.floor(Math.random() * colors.length)];
let td = $('<td>');
let img = $('<img>').attr('src', col).css('width', '30px');
td.append(img);;
tr.append(td);
$('#tab').append(tr);
}
}
let tr = $('<tr>');
for (let j=0; j<5; j++) {
let col = colors[2];
let td = $('<td>');
let img = $('<img>').attr('src', col).css('width', '30px');
td.append(img);;
tr.append(td);
$('#tab').append(tr);
}
};
main();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment