简体   繁体   English

Trumboyg:如何使用 Jquery .html() 或 .text() 放置文本

[英]Trumbowyg: How to put text using Jquery .html() or .text()

How to put retrieved text into Trumbowyg Textarea.如何将检索到的文本放入 Trumbowyg Textarea。 I want to edit saved content using Trumbowyg.我想使用 Trumbowyg 编辑保存的内容。 I have getting some text from database using Jquery Ajax.我使用 Jquery Ajax 从数据库中获取了一些文本。 I am trying to put text using .html() and .text() function, but not working.我正在尝试使用 .html() 和 .text() 函数放置文本,但不起作用。 I am trying to find solution from internet till now not get it.我试图从互联网上找到解决方案,直到现在还没有得到它。

HTML: HTML:

<textarea name="description" class="form-control" placeholder="Enter Description"></textarea>

Jquery:查询:

$(".edit").click(function(){
        var id=$(this).attr("data-id");  
         $.ajax({
                type: "POST",
                url: "ajax.php",
                data: "formName=edit_sales_lead&id=" + id,
                success: function(res){
                    if(res!=""){
                            res=JSON.parse(res);
                            console.log(res[1]);  //test description
                            $("input[name='name']").val(res[0]);   
                            $("textarea[name='description']").html(res[1]);
                    }else{
                        console.log(res);
                    }
                }
            });
    });
document.getElementById('editor').innerHTML = '<p>Your html content</p>';

or as suggested by @Taplar in comments:或者按照@Taplar 在评论中的建议:

$('#editor').trumbowyg('html', "<p>Your content here</p>");

would be another way of loading html content.将是加载 html 内容的另一种方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM