我正在使用 php4 和 jquery,我有一个 php 字符串变量 $content,它存储如下所示的字符串。
<html>
<head></head>
<table>
<tr>
<td>comments:</td>
<td>Good</td>
.....
...n rows
</table>
</html>
所以,现在我想将所有出现的文本“Good”的颜色更改为红色。那么如何编写一个 jquery 函数,它接受 php 字符串 $content 变量并更改每个“Good”单词的颜色(添加样式颜色:红色)并返回它。
最佳答案
纯 PHP 解决方案:
echo str_replace('Good', '<span style="color:red">Good</span>', $content);
关于php - 如何在javascript中修改php字符串变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10203895/