Issue
I want to add text to table header’s dynamically but I can’t think of anything.
This is how I add text to div,
var textForDiv1 = getFromArray.ResourceKey;
$("#someDIVId").text(textForDiv1);
and it works, but how can I do same for a <th>
?
Edit
Html is being added dynamically, but this is how I am adding th
var someRow= "<tr class='someClass' ><th>text1</th><th>text2</th></tr>"; // add resources
$("#Table").append(someRow);
Solution
give your headers an id when creating them and just access them as you would any other element:
$(function(){
var someRow= "<tr class='someClass' ><th id='header1' >text1</th><th>text2</th></tr>"; // add resources
$("#Table").append(someRow);
$("#header1").text("Banana");
});
Answered By – Banana
Answer Checked By – Pedro (AngularFixing Volunteer)