Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 更改字符串中单词的格式_Jquery_Joomla - Fatal编程技术网

Jquery 更改字符串中单词的格式

Jquery 更改字符串中单词的格式,jquery,joomla,Jquery,Joomla,我有一份joomla菜单,上面有“与众不同”、“最好”等项目 每次文本中出现“be”字符串时,我都需要将其加粗 我计划使用jQuery。我看过match、indexof或使用regex之类的表达式,但都被卡住了您可以这样使用 $('#Menu').html($('#Menu').html().replace(/(be )/g, '<strong>be </strong>')); $(“#Menu').html($(“#Menu').html()。替换(/(be)/g,b

我有一份joomla菜单,上面有“与众不同”、“最好”等项目

每次文本中出现“be”字符串时,我都需要将其加粗


我计划使用jQuery。我看过match、indexof或使用regex之类的表达式,但都被卡住了

您可以这样使用

$('#Menu').html($('#Menu').html().replace(/(be )/g, '<strong>be </strong>'));
$(“#Menu').html($(“#Menu').html()。替换(/(be)/g,be);

如果我这样做,为什么不起作用:$(“#Menu').html()。替换(/(be)/g,be)???