In html, a text node contains only pure text. If a hyperlink comes in between it is a separate childNode and it becomes element node. I want to know, that can we manipulate an anchor tag in such a way that it appears as a text node. Like by keeping anchor tag between some span or div tag. I tried it that way didn’t work out. Is there any solution?
Share
Given
you have a paragraph element with three children: a text node, an element node, and a text node.
It sounds like you want all the text within the paragraph node. You can refer to
to get what (I think) you want.
Now if you want to grab the text of the anchor node, as a text node you can do so by recognizing that there is a text node as a child of the anchor node.
I created a demo at http://jsfiddle.net/8Yqqz/1/
The basic idea is that you locate the anchor node, then get its first child. This child will be a text node. The source code of the fiddle should make this clear.