本文介绍了css替换段落标签中的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
已经检查过此问题,但没有找到完全匹配。
Already checked exisitng questions for this, but didn't find an exact match.
我的目标是用小的字符替换网页上的字符image使用css。
My aim is to replace characters (like spaces) on a webpage with a small image using css.
示例:
<p><span>This is a text</span></p>
变为:
<p><span>ThisIMGisIMGaIMGtext</span></p>
(其中IMG代表可见图像(middot-pic for a space fe))
(where IMG stands for a visible image (middot-pic for a space f.e.))
我想不出一个合适的CSS选择器。但是我的一个你们(或女孩)知道一个解决方案。这是可能吗?
I cannot think of a suitable css selector. But myabe one of you guys (or girls) know a solution. Is this possible at all?
推荐答案
由于你没有ID,我假设你想要所有< p>< span> ...< / span>< / p>
。 jQuery将帮助您:
Since you're not having an ID, I assume you want it on all <p><span>...</span></p>
. jQuery will help you:
$(document).ready(function(){
$("p span").html($("p span").html().replace(/ /g,'<img src="yourimg.gif" />'));
});
这篇关于css替换段落标签中的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!