javascript - OnClick event to change cell background -
link jsfiddle
i'm having need alter cell's background color everytime user click on it, can't work!
this script :
$( function() { $('.tk099 td').click( function() { $(this).toggleclass("red-cell"); } ); } );
in tk099
table's class, , don't want td
tag has class affected event. possible? alot!
your selector .tk099 td
takes presidence on .red-cell
because:
.red-cell
(and css cascades) declare .red-cell
later on , create specific/more specific:
.tk099 td { background-color:#eeeeee; text-align:center; border-bottom:1px solid #ccc; border-left:1px solid #ccc; } td.red-cell { background: #f00; /* or other color */ }
jsfiddle
javascript jquery html css onclick
No comments:
Post a Comment