How to create a "bbcode" javascript with replace
This question already has an answer here:
Try
postText.html(postText
.html()
.replace(/[tag]/g,'<span class="tag">')
.replace(/[/tag]/g,'</span>')
);
Ex:
$('.post').html(function(){
return $(this)
.html()
.replace(/[tag]/g,'<span class="tag">')
.replace(/[/tag]/g,'</span>')
})
Demo: Fiddle
链接地址: http://www.djcxy.com/p/16848.html上一篇: 从字符串中多次删除字符