Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a value of td of a selected tr in jquery

Tags:

html

jquery

Below is my table

<table>
    <tr class=chargeTR>
        <td id=chargeTD>
            charge1
        </td>
    </tr class=chargeTR>
        <td id=chargeTD>
            charge2
        </td>
    </tr>
<table>

Below is my jQuery call

$(".chargeTR").each(function() { // this line works fine
        $.get("process.php", {
            value: $(this).find("#chargeTD").val(), // I must be doing something wrong here...
        }, function(theXML){
            alert(theXML);
        });
});

I cannot get the value "charge1" and "charge2".

Can somebody please correct me in this?

like image 382
jaeyun Avatar asked Dec 22 '22 02:12

jaeyun


1 Answers

use .text() or .html() instead of .val(), since .val is intended to get value="" attributes from forms.

like image 97
Jon Bristow Avatar answered Jan 10 '23 05:01

Jon Bristow