Quote (StormHasHe @ 12 Sep 2012 16:51)
I ended up making it, hope it helps you understand.
Code
<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js" type="text/javascript"></script>
<HEAD>
<TITLE>Change BG color on click</TITLE>
</HEAD>
<BODY>
<h1 align="center">Press "R" for Red and "B" for Blue</h1>
<table width="100%" border="1px" cellspacing="0px" bgcolor="#FFFFFF">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>25</td>
<tr>
<tr>
<td>James</td>
<td>27</td>
<tr>
</tbody>
</table>
</body>
<script type="text/javascript">
$(function(){
var cont = 0;
var cell;
$("table").find("td").each(function() {
$(this).css({"text-align" :"center"});
$(this).attr("id", "tdCell" + cont);
cont++;
});
$("td").bind('mouseover', function () {
cell = "#" + $(this).attr("id");
});
$("td").bind('mouseout', function () {
cell = "";
});
$("body").bind('keydown', function (event) {
if (event.which == 82) {
$(cell).css({"background-color" :"red"});
}
if (event.which == 66){
$(cell).css({"background-color" :"blue"});
}
});
});
</script>
</html>
ok thanks, i will check it tomorow i just got out of work and im tired as fkkkkk!!!
btw is this html 5 ? the function? or php? because i saw a lot of $ in php if i remember correctly..