I simply want to remove the text which is after input, any ideas ?
<label class="checkbox">
<input id="forms-element-0-0" name="checkbox[]" value="1" type="checkbox">
remove me
</label>
I simply want to remove the text which is after input, any ideas ?
<label class="checkbox">
<input id="forms-element-0-0" name="checkbox[]" value="1" type="checkbox">
remove me
</label>
I'd skip jQuery for this, if it's only the one input
's following-text, and use:
document.getElementById('forms-element-0-0').nextSibling.nodeValue = '';
To remove the textNode
(rather than simply replace its text with an empty string):
var text = document.getElementById('forms-element-0-0').nextSibling;
text.parentNode.removeChild(text);
If you have a collection of label
elements to work through I'd suggest:
$('label').contents().filter(function(){
return this.nodeType === 3;
}).remove();
References: