So i got this snippet of code:
$(document).ready(function () {
var replacementDoneIn = $("body").html();
var regExMatch = /premier(( {1,5}?)?co(mpany)?([ |\.])?)?/ig;
var replaceWith = "Nikon";
var resultSet = replacementDoneIn.replace(regExMatch, replaceWith);
$("body").html(resultSet);
});
which is some what working for me, but it does not cover more robust and complicated scenario.
I would like to expand find/replace capabilities with a help of jQuery. To properly utilize find/replace of the text inside of the body element excluding any html elements and any attributes and their values.
note: Not being completely certain on how jQuery text() function traverses children of the element it is applied on to.
note: as far as i understand i can loop through all elements in html via $("*")
, but does that create any issues for such script
so if you could direct me to the right path, it would be greatly appreciated. Links to resources that address this already, your advices, all will work. Because for some reason my head produces only complicated solutions, so I am wondering may be there are simpler approach.
Thank you in advance.