Tuesday, December 18, 2012
How to get HTML Table cell value on click event?
In some of the cases we want to access the value of HTML table cell value when we click on particular cell, this can be simply done using client side code only.
Here I am giving simple code to access HTML table cell value.
<script type="text/javascript">
$(document).ready(function () {
$('table[id$=TableName] tr>td').click(function () {
alert($(this).parent()[0].cells[0].innerText);
});
});
</script>
This is JavaScript code; here I have used JQuery to get value. Here first I have integrated one function with table cell. This function will be executed when
we will click on cell. To get cell value I have written this line of code-
alert($(this).parent()[0].cells[0].innerText);
This alert() will display value of cell.
Thanks
Labels:
Alert,
Asp.Net,
HTML Table,
JavaScript,
jquery,
Table cell value
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment