[英]Change Anchor Text while keeping the FontAwesome Icon inlined
I am using WordPress so i could only change the HTML through custom JS. 我正在使用WordPress,因此只能通过自定义JS更改HTML。
This is the HTML 这是HTML
<li class="submit-listing"><a href="http://localhost/proficientlink/post-your-ad/"><i class="fa fa-plus"></i> Submit Listing</a></li>
I already tried all of these: 我已经尝试了所有这些方法:
$(".submit-listing a").html("<i class="fa fa-plus"></i> Post You Ad");
$(".submit-listing a").html(function(){
$(this).find("i").addClass("fa fa-plus");
this.nodeValue = "Post Your Ad";
});
but none of these work. 但这些都不起作用。 I also tried this : How can I get, manipulate and replace a text node using jQuery?
我也尝试过这样: 如何使用jQuery获取,操纵和替换文本节点? , but nothing seems to work with me.
,但似乎无济于事。
Thanks anyway. 不管怎么说,还是要谢谢你。
The first line of your code should be, 您代码的第一行应该是
$(".submit-listing a").html("<i class='fa fa-plus'></i> Post You Ad");
Change the double quotes to single quotes because JavaScript treats them as closing strings. 将双引号更改为单引号,因为JavaScript将其视为结束字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.