I have the following code:
var aggrHTML = $('TBODY#aggr > tr > td > table > tbody > tr > td > nobr > b');
var aggrText = aggrHTML.text();
var newText = "Total" + aggrText.substring(3);
aggrHTML.html(newText);
What I would like to do is alter the above so I select all elements whose id contain 'aggr'.
Many Thanks, Nav
var aggrHTML = $('TBODY[id*=aggr] > tr > td > table > tbody > tr > td > nobr > b');
var aggrText = aggrHTML.text();
var newText = "Total" + aggrText.substring(3);
aggrHTML.html(newText);
Simplest way to achieve that is
var aggrHTML = $("[id*=aggr]");
var aggrText = aggrHTML.text();
var newText = "Total" + aggrText.substring(3);
aggrHTML.html(newText);
If by "all elements" you mean all DOM elements of course.
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