dan dan - 1 year ago 103
jQuery Question

delete text without element inside div after some button

here the code

class="alert alert-danger col-md-offset-1 col-md-10 alert-dismissible"
<button type="button" class="close" data-hide="alert" aria-hidden="true">
<span aria-hidden="true">&times;</span>
myquestion is,, how to remove/delete this text using jquery, just this text only,,

i've tried
$('#user-alert :not(:first-child)').remove();
but it won't work

i also tried
$('#user-alert button.close).text('')
still not work

Answer Source

Try this UPDATED

$( "#YourIdHere" ).contents().filter(function() {
  return this.nodeType === 3;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download