Can you tell me how to remove character @
from this span tag without changing all child html(s)?
$('button').click(function() {
// ...
});
#name {
background-color: #ccc
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span>
<span id="name">
<a href="#">Harry</a>
</span>
says: Hello @<span id="name">
<a href="#">Hermione</a>
</span>
</span><br />
<button>Remove</button>
My idea: get the parent .text()
, split character @
, override parent text (parent.text('')
) and append 2 parts to the parent. But this way has a big problem: all child html(s) wouldn't be kept.