如何从字符串中删除唯一的文本“You”,只留下文本“Kevin Yam, Bryan Ooi”
输出:Kevin Yam、Bryan Ooi
var panel = document.getElementById("panel" + (getlikeid));
var you = document.getElementById("only_you" + (getlikeid));
if (you.innerText === "You") {
panel.remove();
} else if (you.innerText !== "You") {
//execute code
}
<span id="only_you11"> You, Kevin Yam, Bryan Ooi</span>
最佳答案
- 你
.replace()
var text1 = $('span').text().replace(/You,/g, '')
$('span').text(text1);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="only_you11"> You, Kevin Yam, Bryan Ooi</span>
关于javascript - Php Javascript 如何从字符串中删除唯一想要的文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48374378/