Javascript 更改jQuery单元格表值

Javascript 更改jQuery单元格表值,javascript,jquery,html,Javascript,Jquery,Html,我有一个关于javascript和jQuery的问题。我对这件事一无所知。 我使用jQuery表端口。我想知道如何更改一个单元格的值 可能我必须使用这样的东西: $(function() { $("table").tablesorter({ sortList: [[3,1],[0,0]] }); $("table tbody td.discount").click(function() { // randomize a number var resort =

我有一个关于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>

你能把你的问题说得更清楚些吗?我不确定我是否理解你的意思。试试这个,我想更改MyJavaScript函数中的单元格值。可能我必须使用这样的东西:$(“table”).trigger(“updateCell”,[this,resort]);但在这段代码中,“this”是我单击的单元格。对吗?我想更改通用单元格值。例如:我们可以假设我们有一个如下的javascript函数:changeValueCell(numberLine,numberColum)。如何实现此功能?
$(function () {
    $("#myTbl").delegate("td", "click", function () {
        var $this = $(this);
        console.log($this);
        $this.html("New Value");
    });
});