I want this program to show alert when I click the Checkbox, But I am uable to do it, it is not working if i tried to do with checkbox, or it is show undefinied values.
<!DOCTYPE html>
<html>
<head>
<script src="http://ift.tt/2nYZfvi"></script>
<style>
td {border: 1px #DDD solid; padding: 5px; cursor: pointer;}
.selected {
background-color: brown;
color: #FFF;
}
</style>
<script>
$(document).ready(function(){
$("#table tr").click(function()
{
$(this).addClass('selected').siblings().removeClass('selected');
var value1=$(this).find('td:nth-child(2)').html();
var value2=$(this).find('td:nth-child(3)').html();
var value3=$(this).find('td:nth-child(5)').html();
alert(value1+" "+value2+" "+value3);
});
});
</script>
</head>
<body>
<table id="table" border="1">
<tr>
<label for="check">
<td><input type="checkbox" id="check"></td>
<td>Pizza</td>
<td>1000$</td>
<td>1200$</td>
<td>Vegetable Pizza</td>
<td>1</td>
<td>F138</td>
<td>Klik pre detaily</td>
</label>
</tr>
<tr>
<td><input type="checkbox" id="check"></td>
<td>Burger</td>
<td>1000$</td>
<td>1200$</td>
<td>HOT Sanwidtch Burger</td>
<td>1</td>
<td>F138</td>
<td>Klik pre detaily</td>
</tr>
<tr>
<td><input type="checkbox" id="check"></td>
<td>KFC Chicken</td>
<td>1000$</td>
<td>1200$</td>
<td>Spicy Hot Chicken</td>
<td>1</td>
<td>F138</td>
<td>Klik pre detaily</td>
</tr>
</table>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire