更改jQuery单元格表值
Change jQuery cell table values
我有一个关于javascript和jQuery的问题。我对此很陌生。我使用jQuery表排序。我想知道如何更改一个单元格的值。
也许我必须使用这样的东西:
$(function() {
$("table").tablesorter({ sortList: [[3,1],[0,0]] });
$("table tbody td.discount").click(function() {
// randomize a number
var resort = "", // resort variable set to anything BUT false (without quotes) will trigger the automatic resort
discount = '$' + Math.round(Math.random() * Math.random() * 100) + '.' + ('0' + Math.round(Math.random() * Math.random() * 100)).slice(-2);
$(this).text(discount);
// set resort flag to false to prevent automatic resort
// leave the resort flag as undefined, or with any other value, to automatically resort the table
$("table").trigger("updateCell",[this, resort]);
return false;
});
});
在这个例子中,当我点击单元格时,我可以更改它的值。我想把单元格值改成一个我的javascript函数。我该怎么做?
HTML
<table id="myTbl">
<tr>
<td>Joe</td>
<td>White</td>
<td>25</td>
</tr>
<tr>
<td>Joe1</td>
<td>White1</td>
<td>2522</td>
</tr>
</table>
JS
$(function () {
$("#myTbl").delegate("td", "click", function () {
var $this = $(this);
console.log($this);
$this.html("New Value");
});
});
相关文章:
- 使用jquery在单击时在单元格中输入值
- 如何将jQuery/AAJAX结果放入表格单元格
- 使用jQuery只返回选中复选框后的第一个表单元格值
- jQuery-通过AJAX调用动态添加具有值的表单元格
- jQuery如何获取td单元格值
- 在jQuery中输出单击单元格的内容
- jQuery根据相关复选框选择求和单元格
- jQuery表 - 如何根据选中的复选框在单元格中写入文本
- 嵌套的 Jquery 每个 2D 数组错误地重复表单元格
- JQuery insertAfter();移动下一个表格单元格
- 使用jquery数据表,我可以't在不破坏FixedHead的情况下生成单元格colspan=3
- 如何使用jquery获取表单元格中子元素的值
- JQuery:如何在单元格中选择表的行,而不是表的行
- jQuery - 如果 img 在单元格内
- 存在事件的单元格的jQuery DatePicker背景色(加载时)
- jQuery从html单元格中读取值
- 如果鼠标悬停得很快,Jquery鼠标移动会错过一些单元格
- 如何让jQuery.change()引用Handontable上的单元格
- 用JQuery在廉价的excel表格上标记最后一个单元格
- 集& lt; h2>文本基于表格单元格- jQuery