I want to get a selected row val开发者_开发百科ue of a table when we click on a row, how can i do this?
<script type="text/javascript">
window.onload=function() {
var table = document.getElementById("table1");
var tablerows = table.rows;
for (var i=0, n=tablerows.length;i<n;i++) {
tablerows[i].onclick=function() {
alert(tablerows[i].textContent?tablerows[i].textContent:tablerows[i].innerText)
}
}
}
</script>
精彩评论