I am very new to jQuery and JavaScript. I have a small question. Let's say i have a HTML table like the following
<Table id="mytable">
<tr id="element">
<td>value</td>
<td>text</td>
</tr>
</Table>
In the above example i know the row id and i want to change the value of the second column of the row with that particular id.
I need a result something like the following:
<Table id="mytable">
<tr id="element">
<td>value</td>
<td>ChangedText</td>
</tr>
</Table>
So my question is: how can I select the 2nd column of the first row with a given id in order to change the value?
Columns can be selected using column(). select() or columns(). select() API methods. You can enable single or multiple items selection using select.
The select() method is an inbuilt method in jQuery which is used when some letters or words are selected (or marked) in a text area or a text field. Syntax: $(selector). select(function);
In Mozilla Firefox, users may highlight only certain rows, columns, or cells of an HTML table by holding down the Ctrl on the keyboard and click each cell individually.
$("#element td:nth-child(2)").text('ChangedText');
Here's an example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With