Reputation: 8587
so I have a div:
<div id="divId">some content in here</div>
And I want to get the content of this div, so I do what I always do:
<script type="text/javascript">
//<![CDATA[
Event.observe(window, 'load', function() {
var divContent = $('divId');
console.log(divContent);
});
//]]>
</script>
But instead of having the content of the div logged out in firebug, I get [object HTMLDivElement]
.
What am I missing?
nb: protoype library is loaded in the head of my page.
Upvotes: 0
Views: 61
Reputation: 8587
well, I was missing .innerHTML
:
<div id="divId">some content in here</div>
And I want to get the content of this div, so I do what I always do:
<script type="text/javascript">
//<![CDATA[
Event.observe(window, 'load', function() {
var divContent = $('divId').innerHTML;
console.log(divContent);
});
//]]>
</script>
Upvotes: 1