View Full Version : how to access value in DIV tag

antonio kapochi
10-17-2006, 10:27 AM
Hi everyone,

i am new to JavaScript, i am writing this js to get a value from the div tag but :(

the DOM inspector shows tree like

-DIV (id=p1)
-DIV (id=p2)
#text (<-- this is the value that i want to retrieve)

if i try
document.getElementById(p1).lastChild it returns [object HTMLDivElement]

any idea what i am doing wrong?

10-17-2006, 11:54 AM

You need to grab the value, try:

Good luck;

antonio kapochi
10-17-2006, 12:29 PM

var abc = document.getElementsByTagName("name");
var value_to_store = abc[0].firstChild.nodeValue;


EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum