开发者

JQuery only highlight prepended text

开发者 https://www.devze.com 2022-12-13 06:28 出处:网络
开发者_高级运维I need to highlight the text that I prepend; not the entire string. My code below highlights everything.

开发者_高级运维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

    精彩评论

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