我一直在尝试在我的 Wordpress 站点上的 css 类之后 append 此元素:
<span class="blink">_</span>
我不能改变文件结构,但我可以使用 CSS/Jquery。代码片段在我将它随机放入时有效,但现在我想使用 CSS/Jquery append 它,以便我所有的帖子标题都用闪烁的下划线 (_) 结束。
我目前的代码看起来像这样,但它不起作用:
$(".intro-title").after("<span class="blink">_</span>");
我已经尝试过在 -tag 前后使用和不使用“”,仍然没有成功。
如果我做一个
.intro-title::after { content: "Hello";}
它工作得很好。所以我知道 Wordpress-setup 允许我在标题后 append 一些东西。我还需要将我的函数包装到这样的标签中:
jQuery(function($){ ... });
希望可以将我闪烁的小下划线 append 到“intro-title”类的所有 h1 - 但现在我被卡住了!
最佳答案
尝试这样的事情。
$(".intro-title").after("<span class='blink'>_</span>");
$(".intro-title").after("<span class='blink'>_</span>");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<p class="intro-title">This is paragraph</p>
或使用追加。
$(".intro-title").append("<span class='blink'>_</span>");
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<p class="intro-title">This is paragraph</p>
使用 Css 样式
.intro-title::after{
content:'_';
}
<p class="intro-title">This is Paragraph</p>
关于jquery - 使用 jQuery 将 <span>-tag append 到 css header-element,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41635443/