javascript – jQuery Remove string from string

javascript – jQuery Remove string from string

pretty sure you just want the plain old replace function. use like this:

myString.replace(username1,);

i suppose if you want to remove the trailing comma do this instead:

myString.replace(username1,,);

edit:

here is your site specific code:

jQuery(#post_like_list-510).text().replace(...) 

To add on nathan gonzalez answer, please note you need to assign the replaced object after calling replace function since it is not a mutator function:

myString = myString.replace(username1,);

javascript – jQuery Remove string from string

If you just want to remove username1 you can use a simple replace.

name.replace(username1,, )

or you could use split like you mentioned.

var name = username1, username2 and username3 like this post..split(,)[1];      
$(h1).text(name);

jsfiddle example

Leave a Reply

Your email address will not be published. Required fields are marked *