开发者

JQuery only highlight prepended text

开发者_高级运维I need to highlight the text that I prepend; not the entire string. My code below highlights everything.

jQuery("#foo").prepend("<li>Addition li</li>").effect("highlight", {}, 1000)

So I only want to highlight that new

  • . How can I do this?


    Use prependTo() and go the other way instead of prepend():

    $("<li>Addition li</li>").effect("highlight", {}, 1000).prependTo("#foo");
    

    or you may want to prepend first:

    $("<li>Addition li</li>").prependTo("#foo").effect("highlight", {}, 1000);
    


    Identify the prepended text with a class and style it in your css? This may or not be suitable depending on your requirements, but i'd say its the simplest approach.

  • 0

    上一篇:

    下一篇:

    精彩评论

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

    最新问答

    问答排行榜