我试图从jQuery中的字符串中删除一个字符串.
Here is the string:
username1, username2 and username3 like this post.
我想从这份名单中删除username1,
个.
我try 使用.split(', ')
将列表添加到数组中,但遇到错误.我假设错误是因为不是每个单词后面都有逗号.
I always want to remove the fist item from the list. username1
is just an example username. The first item will always be the username of the currently logged in user if they have liked this post.
我试过了:
var updated_list = $('#post_like_list').html().replace('username1, ', '');
$('#post_like_list').html(updated_list);
但这并没有更新名单.但是,当使用.text()
而不是.html()
时,它确实会更新列表,但是我在列表中有需要保留的链接.