How to Replace Text On Page using jQuery

Today, for one of my requirement, I have to replace all the (.)dots in my page with "---". The basic idea find all the (.) in HTML and replace them with "---". This can be done very easily with jQuery. First you replace the (.) with "---" and assign it to any variable then you need to assign back that value to HTML of the page. See below code.

$(document).ready(function() {
    var strNewString = $('body').html().replace(/./g,'---');
    $('body').html(strNewString);
});

Instead of, (.) or "---", text can be anything. All you need is to make change in the replace function arguments and you are good to go.

See live Demo and Code.

Feel free to contact me for any help related to jQuery, I will gladly help you.



Responsive Menu
Add more content here...