วันเสาร์ที่ 6 พฤศจิกายน พ.ศ. 2553

jquery row highlight


<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>d</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<style type="text/css">
.silver {color:silver;background-color:#990000;}
.green {color:#009999;}
.red {color:#FF0000;}
</style>
<script type="text/javascript">
$(function(){
$('.green').click(function(e){
e.preventDefault();
$(this).parents('.row').find('td').removeClass('silver');
});
$('.red').click(function(e){
e.preventDefault();
$(this).parents('.row').find('td').addClass('silver');
});
});

</script>

</head>
<body>


<table border="1" width="70%">
<?php foreach(range(1,5) as $i):?>
<tr class="row"><td><?php echo "TEST$i";?></td><td><a href="#" class="red">red</a></td><td><a href="#" class="green">green</a></td></tr>
<?php endforeach;?>
</table>


</body>
</html>

ไม่มีความคิดเห็น:

แสดงความคิดเห็น