Hi there rshekhar21,
unfortunately for you, but fortunately for me, I don't do or know anything about "
JQuery" other than the name.
But if you are interested, I would code it like this...
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>color code</title>
<style type="text/css">
body {
min-width:315px;
}
#color {
margin-bottom:10px;
text-align:center;
}
#table1 {
width:100%;
border-spacing:2px;
}
#table1 td {
height:40px;
padding:0;
cursor:pointer;
}
#table1 td:hover {
box-shadow:inset 0 0 10px rgba(0,0,0,1.0);
}
</style>
<script type="text/javascript">
(function() {
'use strict';
function init(){
var cells=document.getElementById('table1').getElementsByTagName('td');
for(var c=0;c<cells.length;c++) {
cells[c].onclick=function() {
document.getElementById('cc').value=this.style.backgroundColor;
}
}
}
window.addEventListener?
window.addEventListener('load',init,false):
window.attachEvent('onload',init);
})();
</script>
</head>
<body>
<form action="#">
<div id="color">
<label for="cc">Color Code</label>
<input id="cc" type="text" readonly="readonly">
<input type="reset" value="clear">
</div>
</form>
<table id="table1"><tr>
<td style="background-color:#0072c6"> </td>
<td style="background-color:#b2e6f9"> </td>
<td style="background-color:#d9fcea"> </td>
<td style="background-color:#00ccff"> </td>
</tr></table>
</body>
</html>
coothead