voidstate
voidstate

Reputation: 7990

How to Get Text Node with Dojo JS

I am trying to get the text from within a tag - but that tag has a nested node, too which I don't want. How do I just get the text?

For example

<div id="i_want_the_text_in_this_div">
  <span id="but_not_this_one">
   ignore this text
  </span> 
  keep this text
</div>

Upvotes: 4

Views: 5055

Answers (2)

Alfredo Carrillo
Alfredo Carrillo

Reputation: 316

Use dojo.attr(node, 'innerHTML') as textContent does not work in IE

Upvotes: 2

pp19dd
pp19dd

Reputation: 3633

Try: dojo.query('#i_want_the_text_in_this_div')[0].lastChild.textContent;

Upvotes: 7

Related Questions