Shan  Luo
Shan Luo

Reputation: 63

How to add some text after the text in the span using jquery?

I want to insert some text after the text in the span as follows. I want add the &times after Tag1 like "Tag 1 &times". But it the &times is after the </span>, which means outside the span. Thanks.

BTY, is there any good suggestion for the delete button for the tags?

html:

<li><span>Tag 1</span></li>

jquery:

$('li span').append('<p>&times</p>');

Upvotes: 1

Views: 4834

Answers (2)

kalley
kalley

Reputation: 18462

var span = $('li span');
span.html(span.html() + '&times');

Is this what you're looking for?

If you want to do it in one line:

$(that).find('span')[0].innerHTML += '&times';

Upvotes: 5

Sphinx
Sphinx

Reputation: 306

$('li span').after('&times');

Upvotes: 0

Related Questions