Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

div tag text

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to get the content or body of <div> tag from java script
ex: <div id="sel_1" >
<a href="find('sel_1')" >[-]</a>adding some addtional comments
</div>

java script :

var cmtTxId = document.getElementById('sel_1');
var text = cmtTxId.innerHTML;\\or cmtTxId.value\\

/* above expression giving me <a href="find('sel_1')" >[-]</a>adding some addtional comments*/
\\ i need only the text "adding some addtional comments"
Is there any other way to get only the text....not other inner tags
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Take a look at this:

http://www.javascriptkit.com/domref/nodetype.shtml

Eric
 
prajwala solanki
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mine is kinda triky...
I din't find much info from the link you provided....
mine is two different tags under a div tag

Ex: <div id="text">
<a href="com"></a>
hello this text is not under <a> tag....
</div>
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The answer was there in a way, I was seeing if you could make sense out of it.

Lets try this:


Eric
 
prajwala solanki
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow.... Its working...Thanks alot...
actually I am not good at javascript...
Thanks again..
 
Look ma! I'm selling my stuff!
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic