Skip to content

Instantly share code, notes, and snippets.

@DewofyourYouth
Created October 18, 2018 14:48
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 DewofyourYouth/78521c4548cf091a59e9edd60e88974c to your computer and use it in GitHub Desktop.
Save DewofyourYouth/78521c4548cf091a59e9edd60e88974c to your computer and use it in GitHub Desktop.
Multiplication Table - Web School
<div class="container">
<div class="row">
<div class="col-12">
<div id="multi-table"> </div>
</div>
</div>
</div>
var table = document.getElementById('multi-table');
function makeTable(){
var tableContent = `<table class="table">`;
for(var i = 1; i < 11; i ++){
for(var j = 1; j < 11; j++){
tableContent += `${j == 1 ? "<tr>" : ""}<td ${i == 1 || j == 1 ? 'class="gray"' : ''} id="cell-${j*i}">${j*i}</td>${j == 10 ? "</tr>" : ""}`;
}
}
tableContent += "</table>";
return tableContent;
}
table.innerHTML = makeTable();
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
.table {
text-align: center;
}
.gray {
background-color: #ccc;
font-weight: bold;
}
#cell-25 {
background-color: #00ff00;
}
#cell-100 {
color: #fff;
font-weight: bold;
background-color: #0000ff;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css" rel="stylesheet" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment