gpt4 book ai didi

jquery - 选择 DIV 中的特定字符串并对其进行格式化

转载 作者:太空宇宙 更新时间:2023-11-04 04:45:56 25 4
gpt4 key购买 nike

div 中的示例文本:

I am at the first line.
I am at the second line.
I am at the third line.
I am at the end of the first paragraph.

问题:我想制作一个脚本:

  1. All "first" will be colored blue
  2. All "second" will be colored green
  3. All "third" will be colored red and BOLD

Please see the non working code here..

添加了代码链接

最佳答案

给你

$(function(){   
$('#text').attr('value','first').css('color','#0000FF');
$('#text').attr('value','second').css('color','#00FF00');
$('#text').attr('value','third').css('color','#FF0000');
$('#text').attr('value','third').css('font-weight','bold');
});

关于jquery - 选择 DIV 中的特定字符串并对其进行格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14493162/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com