开发者

jTruncate / live()

开发者 https://www.devze.com 2022-12-17 03:12 出处:网络
I been looking at http://blog.jeremymartin.name/2008/02/jtruncate-in-a开发者_如何转开发ction.html.It doesn\'t seem to work for html added to the page after page load.

I been looking at http://blog.jeremymartin.name/2008/02/jtruncate-in-a开发者_如何转开发ction.html. It doesn't seem to work for html added to the page after page load.

Does anyone know how that would work or if there is a better solution?


The simplest solution to your problem is to call the jTruncate constructor on the HTML returned by your AJAX calls. Like so:

$.ajax(
{
    success: function (html) // HTML is returned
    {
        // Enable jTruncate on the HTML
        var truncatedHTML = $(html).jTruncate(/* options */);

        // Append the HTML to your page
        $("element to append to").append(truncatedHTML);
    }
});
0

精彩评论

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

关注公众号