I would like to be able to determine if a parent node, whose ID I know, has direct child nodes, and if such nodes are detected, remove them. The nodes, if they exist, will always follow some text, so I don’t think I can use firstChild or lastChild.
Ideally, I would use Javascript to minimize the performance hit. Although JQuery would also work if necessary.
The code is like this:
<a id="anchorID">some text
<span class="spanClass">some span text</span>
</a>
Any help, as always, is appreciated.
If you’d like to remove the child nodes in your anchor, and you’re ok with jQuery, then it’s quite simply:
EDIT
You want to remove the span only?
That will remove all spans in the anchor. If you wanted to remove only the first span, then you could do