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
Post a Comment