...

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)
-NAME
#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?

Brandoe85
10-17-2006, 11:54 AM
Hi,

You need to grab the value, try:
document.getElementById("p1").lastChild.nodeValue

Good luck;

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


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

thanks



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum