开发者

How to update table cell value in Jquery

开发者 https://www.devze.com 2023-02-20 06:42 出处:网络
I ma new to jquery. I would like to update the table cell from Jquery. The Php is as below. For example I would like to update \"firsttotal\" with a different value. Please help.

I ma new to jquery. I would like to update the table cell from Jquery.

The Php is as below. For example I would like to update "firsttotal" with a different value. Please help.

<tr>
                        <td class="Left">Total</td>
                        <td></td>
                        <td id="firsttotal"><?php echo number_format('%.2n', $Total_Calculated_Cash); ?&g开发者_JAVA百科t;</td>
                        <td id="cashcalculator_total"><a href="#"><?php echo number_format($Total_Actual_Cash, 2); ?></a></td>
                        <td><?php echo number_format($Total_Calculated_Other, 2); ?></td>
                        <td><?php echo number_format($Total_Actual_Other, 2); ?></td>
                    </tr>


Get the td element and set the value like so:

<script type="text/javascript">
    var newValue = 6;
    $("#firsttotal").text(newValue);
</script>


since anchor is inside TD, you should use jQuery('td#cashcalculator_total a')

<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js"></script>
<script type="text/javascript">
    jQuery(function() {
        jQuery('td#cashcalculator_total a').html('XXX');
    });
</script>


$('td#firsttotal').html(value);

or

$('td#firsttotal').text(value)


$('td#firsttotal').text(value)

so something like this would work

$('td#firsttotal').text("test")

If you wanted to add HTML tags into it then you can use this

$('td#firsttotal').html("<p>test</p>")


jQuery('#firsttotal').html("new Value");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号