DOM/[removed] get text after tag

前端 未结 6 898
Happy的楠姐
Happy的楠姐 2021-01-05 00:59

How do I get the text \"there\" that comes after a tag in an html document:

hellothere

I see that the

6条回答
  •  感情败类
    2021-01-05 01:41

    use this .. http://jsfiddle.net/2Dxy4/

    This is your HTML --

    hello there

    In your JS

    alert(document.getElementById("there").lastChild.textContent)​
    

    or

    alert(document.getElementById("there").childNodes[1].textContent)​
    

提交回复
热议问题