使用CSS或JavaScript识别设置单词或短语,并仅以不同的方式(例如,尺寸,尺寸)



第一个向我的编码人员提出的第一个适当问题,所以这里;

我有一个晦涩的请求,以使其在他的"诀窍"报告软件中,每当"第一份作业"一词出现在生成的桌子中时,它的格式化为Bold&彩色红色。

例如

|第四工作|第七任务|第二工作| 1st Job |第9工作|

我正在沿我的suedocode中的线条思考:

if text displayed ("1st Job") {
format text:
font-weight: bold;
font-color: Red;
}

执行上述格式的唯一选项是JavaScript&CSS

我仍在学习CSS和JavaScript的复杂性,每天都在我的大脑中插入我的大脑,但尚未在任何地方遇到这个请求。

请如果有人知道可能的解决方案,我将非常感谢。

非常感谢al

$('div, p').each(function() {
  var job = $(this).text().replace(/1st Job /g, "<font>1st Job </font>");
  $(this).html(job);
});
font {
  color: red;
  font-size: 10px;
  font-weight: bold;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<section>
  <p>1st Job Ipsum rule britannia lorem fish and chips ipsum going to the loo cheers mate crumpets mate off to the pub good day 1st Job harry potter cup of tea cup of tea crumpets God save the queen jolly good show rule britannia cheerio! bangers and mash</p>
</section>

刚刚意识到我早先用纯JavaScript

解决了这一点
var table = document.getElementById("table1");
for (var i = 0, row; row = table.rows[i]; i++) {
   for (var j = 0, col; col = row.cells[j]; j++) {    
         if (col.innerText == "1st Job") { // You might want to look at other solutions in case the TD shouldnt be case sensitive and so on
             col.style.backgroundColor = "#f00"; //or the actuall styling you want
         }
    }
}

相关内容

最新更新