Код: Выделить всё
$('#submit').on('click', function makeGrid(event) {
var r = $('#inputHeight').val(); //assign variable r the rows input
var c = $('#inputWeight').val(); //assign the variable c the column input
$("table").empty(); // removing previous table's children
for (var i = 0; i < r; i++) {
$('table').append('');
for (var j = 0; j < c; j++) {
$('tr:last-child').append('');
}
}
// taking the clcik on the table sell and changing the background-color val
$("table tr td").on('click', function() {
$(this).css('background-color', $('#colorPicker').val())
});
event.preventDefault(); // preventing default from happening
});Код: Выделить всё
body {
text-align: center;
}
h1 {
font-family: Monoton;
font-size: 70px;
margin: 0.2em;
}
h2 {
margin: 1em 0 0.25em;
}
h2:first-of-type {
margin-top: 0.5em;
}
table,
tr,
td {
border: 1px solid black;
}
table {
border-collapse: collapse;
margin: 0 auto;
}
tr {
height: 20px;
}
td {
width: 20px;
}
input[type=number] {
width: 6em;
}Код: Выделить всё
Lab: Pixel Art Maker
Choose Grid Size
Grid Height:
Grid Width:
Pick A Color
Design Canvas
Подробнее здесь: https://stackoverflow.com/questions/496 ... ect-jquery
Мобильная версия