简体   繁体   English

jQuery仅突出显示前置文本

[英]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() : 使用prependTo() ,而不是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? 用类标识前置文本并在CSS中设置样式? This may or not be suitable depending on your requirements, but i'd say its the simplest approach. 根据您的要求,这可能不合适,但我会说这是最简单的方法。

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

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