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 

fiddle


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

javascript - Backbone.js getting target attribute -

html - Repeat image to extend header to fill screen -