JQuery replace方法 实现全文替换

只有我是water
var reg = new RegExp(",","g");
//g表示全文替换
var res = awards.replace(reg,"<br/>");
// <br/>为需要替换的字符
<script>    
    function test(e){
        var id = e;
                $.ajax({
                    url:'{:U('Home/Teacher/award')}',
                    data:{"id":id},
                    type:'post',
                    dataType : 'json',
                    success: function(data){
                        //console.log(data.cname);
                        var awards = data.awards;
                        var reg = new RegExp(",","g");
                        var res = awards.replace(reg,"<br/>");
                        $('.my-dialog .name').html(data.cname);
                        $('.my-dialog .text').html(res);
                        $('.my-dialog').fadeIn();
                    },
                    error: function(){
                        alert("当前网络状态不好,请重新尝试!")
                    }
                });
            }
</script>
阅读 585
2 声望
0 粉丝
0 条评论
2 声望
0 粉丝
文章目录
宣传栏