javascript - jQuery Remove string from string -


i trying remove string string in jquery.

here string:

username1, username2 , username3 post. 

i remove username1, list. tried adding list array using .split(', ') got error. i'm assuming error because not every word has comma after it.

i want remove fist item list. username1 example username. first item username of logged in user if have liked post.

i have tried:

  var updated_list = $('#post_like_list').html().replace('username1, ', '');   $('#post_like_list').html(updated_list); 

but didn't update list. update list when using .text() instead of .html() have links inside list need preserve.

pretty sure want plain old replace function. use this:

mystring.replace('username1',''); 

i suppose if want remove trailing comma instead:

mystring.replace('username1,',''); 

edit:

here site specific code:

jquery("#post_like_list-510").text().replace(...)  

Comments

Popular posts from this blog

Javascript line number mapping -

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -