I have a question about javascript and jQuery. I'm new about this. I use jQuery tablesort. I would to know how can I change the value of one cell.
Probably I have to use something as this:
$(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;
});
});
in this example I can change the cell's value when I click on it. I would to change the cell value into one my javascript function. How can I make this?
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");
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.