javascript - Get pure text from HTML before a tag -
i have editor text in html following:
<div>hi<p>hello</p>bye</div>
expected result :
div : hi
so here need text before tag. tried using $(div).text() gives hi hello bye, whereas need text before tag.
can me how write javascript function? thank you.
var div = document.getelementsbytagname ("div") [0]; alert (div.childnodes[0].data );//hi
Comments
Post a Comment