How can i replace some text by another text in a $('#myId').attr('value') of a textarea ?
I tried something like this :
$(function() {
    var selection;
    var replaceStr;
    var prependStr = "";
    var appendStr = "";
    var temp = "";
    $('input[type="button"]').click(function() {
        if($(this).attr('id') == 'underline')
        {
            prependStr = "<span style = 'text-decoration: underline;'>";
            appendStr = "</span>";
        }
        else if($(this).attr('id') == 'italic')
        {
            prependStr = "<span style = 'font-style: italic;'>";
            appendStr = "</span>";
        }
        else if($(this).attr('id') == 'bold')
        {
            prependStr = "<span style = 'font-weight: bold;'>";
            appendStr = "</span>";
        }
        else if($(this).attr('id') == 'center')
        {
            prependStr = "<span style = 'text-align: center;'>";
            appendStr = "</span>";
        }
        else if($(this).attr('id') == 'link')
        {
            prependStr = "<a href = ''>";
            appendStr = "</a>";
        }
        else if($(this).attr('id') == 'img')
        {
            prependStr = "<img src = '";
            appendStr = "' />";
        }
        else if($(this).attr('id') == 'h1')
        {
            prependStr = "<h1>";
            appendStr = "</h1>";
        }
        else if($(this).attr('id') == 'h2')
        {
            prependStr = "<h2>";
            appendStr = "</h2>";
        }
        else if($(this).attr('id') == 'h3')
        {
            prependStr = "<h3>";
            appendStr = "</h3>";
        }
        $('#page').focus();
        selection = window.getSelection();
        if(selection != '')
        {
            replaceStr = prependStr+selection+appendStr;
            temp = $('#page').attr('value');
            temp.replace(selection, replaceStr);//Not working
            $('#page').attr('value', temp);
        }
    });
});
The whole code is working, exept the function .replace(). I googled a lot of things, but i didn't found a function to do this on a $('#page').attr('value').
 
     
     
    