1

I am using WordPress so i could only change the HTML through custom JS.

This is the 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?, but nothing seems to work with me.

Thanks anyway.

crosse
  • 27
  • 3
  • Welcome to Stack Overflow. I'm glad you were able to get your issue resolved. Please see [What should I do when someone answers my question?](https://stackoverflow.com/help/someone-answers) and consider accepting one of the answers below so that the issue is marked as resolved on the site. – FluffyKitten Aug 27 '17 at 15:11

2 Answers2

0

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.

Nicholas
  • 156
  • 8
0

Using a replace works:

$('.submit-listing a').html(function (i, el) {
  return el.replace('Submit Listing', 'Post your ad');
});

DEMO

Andy
  • 61,948
  • 13
  • 68
  • 95