I am trying to select all elements on the page which have the string 'aggr' as part of their id value. Then I am trying to replace the text 'Sum 'in these elements to 'Total'.
My JQuery is below but doesn't seem to be working....
$('TBODY[id*=aggr]').each(function(i){
var aggrHTML = $('TBODY[id*=aggr]');
var aggrText = aggrHTML.text();
var newText = aggrText.replace("Sum","Total Holiday Leave")
aggrHTML.html(newText);
});
Try this:
$('TBODY[id*=aggr]').each(function(i){
$(this).html($(this).html().replace("Sum","Total Holiday Leave"));
});
Try something like this
$('TBODY[id*=aggr]').each(function(i){
var aggrText = $(this).text();
var newText = aggrText.replace("Sum","Total Holiday Leave")
$(this).html(newText);
});
I think that will work.
Basically you it iterates over a set of objects, but you have to use $(this) to get the current object.
I left it the way you had it so you can understand it more.