Skip to main content
GameDev.net gamedev.net
🔒 Locked

Javascript access to html text

Started by Symphonic Dec 30, 2008 at 1:00 PM 3 replies 1.2k views
Original Post
Symphonic
Symphonic
So I have this HTML table which contains a slew of these:

<td id="id_0_0">
   
???
</td>
where ??? is a textual representation of an integer. What I would like to do is get read-only access to that text in &#106avascript. Is this possible?
Geordi
George D. Filiotis
LockeCole
LockeCole
I remember the name innerhtml and a quick google seems to confirm it.

http://www.google.com/search?q=&#106avascript+inner+html
Symphonic
Symphonic
Thankyou, my own digging turned up the same thing, using jsquery or getelementbyid() it is possible to use the element's innerHTML prop to access the underlying text.

document.body.innerHTML is a more top-level brutish way to get what I want.
Geordi
George D. Filiotis
Feralrath
Feralrath
Yes, document.getElementById('myid').innerHTML will work just fine.
taby
taby
Quote:
Original post by Feralrath
Yes, document.getElementById('myid').innerHTML will work just fine.


That is totally a neat trick. I didn't realize you could do that. Now I gotta come up with a use for it. :) Rate++.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.