So. I have 2 input (x,y) and when press submit code is draw divs (example: 5x5). I want to change divs background color when div is clicked.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Feladat10</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<form method="post">
<input type="text" name="x"/>
<input type="text" name="y"/>
<input type="submit" name="submit"/>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$x = $_POST['x'];
$y = $_POST['y'];
echo "<br/>";
for($i=1; $i <= $x; $i++)
{
echo "<br/><div class='tile'>".$i."</div>";
for($j=1; $j < $y; $j++)
{
echo "<div class='tile'>".$j."</div>";
}
}
}
?>
Im trying with this code:
<script>
$(function () {
$(".tile").click(function () {
$(this).css('background-color', '#000000');
});
});
</script>
But its not working. Any ideas how can I fix this?