Good evening.
I have a problem with jquery. I create table with jquery when a person choose width and height in a form. It works, but the problem is that I need to change table cell color on click which I get from color picker. So two problems are:
I don’t know how to put colorpicker value to the click function to change cells in that color.
I don’t know why but I can’t click on the cells, I mean if the table is already exists before loading the page and it is in html document I can click and change the color but if it is not exist and creates live with the input form by the user I can’t change the color.
my js code
function makeGrid() {
$('.gridForm').submit(function(e) {
e.preventDefault();
$('#pixels').html('');
x=$('#gridHeight').val(); // value of height
y=$('#gridWidth').val(); // value of width
for(i=0; x>i;x--){
$('#pixels').append('<tr><td></td></tr>');
}
for(j=1; y>j ;y--){
$('tr').append('<td></td>');
}
});
}
makeGrid();
$('td').click(function(){
$('.color').$('#colorCanvas').val(); //value from the color picker
$('td').toggleClass(' .... ');
});
I create a table with the help of the input form where I choose width and height of the table and it creates dynamically on the page and all I need is to change the color of the each cell I click on to the color which is chosen in the Color-picker on the page and make it white again if I click again on it.
function makeGrid() {
$('.gridForm').submit(function(e) {
e.preventDefault();
$('#pixels').html('');
x=$('#gridHeight').val(); // value of height
y=$('#gridWidth').val(); // value of width
for(i=0; x>i;x--){
$('#pixels').append('<tr><td></td></tr>');
}
for(j=1; y>j ;y--){
$('tr').append('<td></td>');
}
});
}
makeGrid();
$('td').click(function(){
$('.color').$('#colorCanvas').val(); //value from the color picker
$('td').toggleClass(' .... ');
});```