Skip to content Skip to sidebar Skip to footer

Find And Replace For Whole Page

I'm trying to create a Find and Replace for the whole page. I'm Using findandreplace which is a mini-plugin which is: function findAndReplace(searchText, replacement, searchNode) {

Solution 1:

I added the following code at the end of your script. It takes input from a prompt but it will 'replace all', not just the one that you click.

$('span[id^=highlight]').live('click', function () {
    replacePrompt = prompt('Replace Word with:','{INPUT HERE}');
    findAndReplace(document.getElementById('fText').value, function() {
        return '<span class="highlight2" style="background: white;color: black;">' + replacePrompt + '</span>';
    });
    return false;
})

Maybe I can work something out after going through your findAndReplace function..

UPDATE: A solution is to not use the findAndReplace plugin at all. I am still not sure but this is probably what you want.

$('span[id^=highlight]').live('click', function () {
    replacePrompt = prompt('Replace Word with:','{INPUT HERE}');
    $(this).text(replacePrompt);
})

Post a Comment for "Find And Replace For Whole Page"