I have table like below
<table>
<tr> <th>Document</th> <th>...</th></tr>
<tr><td>...</td>... </tr>
...
</table>
Now I want to change the text of th "Document" to "Marketting Document/URL"BY jQuery... Please help me!!!
$("table tr>th:first").html("Marketting Document/URL");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table>
<tr><th>Document</th> <th>1</th></tr>
<tr><td>2</td><td>3</td> </tr>
</table>
Try something like this:
console.log($("table tr>th:first").html("Marketting Document/URL"));
You can try this : use jQuery selector to get first tr
and then fist th
inside it. Then use .text()
or .html()
method to update your desired value.
$(function(){
$('table tr:first th:first').text('Marketting Document/URL');
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<table>
<tr>
<th>Document</th>
<th>second header</th>
</tr>
<tr>
<td>first td</td>
<td>second td</td>
</tr>
</table>
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