如何在没有Click事件的情况下获取HTML单元格值我需要在没有任何警报功能的情况下直接获取Cell值
HTML
<table runat="server" id="Rightbar" class="table"> <tr><th>Income</th><td id="TableIncome" runat="server">$1230</td></tr> <tr><th>Reimbursement</th><td id="TableReimbursement" alert="Total()" runat="server">$1230</td></tr> <tr><th>Expenses</th><td id="TableExpenses" alert="Total()" runat="server" class="text-danger">$1230</td></tr> <tr class="info"><th>Net Total</th><td runat="server" id="NetTotal">$1230</td></tr> </table>
的Javascript
var txt1 = document.getElementById("TableReimbursement");
var Cells = Row.getElementsByTagName("td"); alert(Cells[0].innerText);
alert(document.getElementById("myTable").rows[0].cells[0].innerHTML);
var Value = document.getElementById("Rightbar").rows[0].cells.namedItem("TableIncome").innerHTML
答案 0 :(得分:0)
使用此Demo Here
$(document).ready(function(){
alert('Label -'+$('#Rightbar tr th:first').html());
alert('Value -'+$('#Rightbar tr td:first').html());
});