开发者

replace it's not working

i don't know what's the cause but i just want to replace the caraceters with this values but i doesn't work could anybody see what i'm doing wrong??

$(document).ready(initialize);

function initialize() {
    $messageValues = $("#messagePreview");
    $("#txtMessageFields").keyup(previewData);

}

function previewData() {
    $messageValues.html('');
    var aux = this.value;
    aux.replace("#", '<span class="fieldText">');
    aux.replace('!', '</span>');
    $messageValues.append('开发者_如何学Go<p>' + aux + '</p>');
}

thanks for your time


replace is a function that returns a value; it doesn't modify the original string. Instead, assign aux to the value returned by replace:

 aux = aux.replace("#", '<span class="fieldText">');
    aux = aux.replace('!', '</span>');


.replace doesn't change the original string, it returns the modified string. You need to assign the returned value to something:

aux = aux.replace("#", '<span class="fieldText">');
aux = aux.replace('!', '</span>');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜