I am trying to remove a string from a string in jQuery.
Here is the string:
username1, username2 and username3 like this post.
I would
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