You need to select the element correctly first. It doesn't (and can't) have a name
attribute so getElementsByName
is wrong. You can use getElementsByClassName
or (with more limited support) the new and shiny querySelector
:
var div = document.querySelector('.question');
Then you need to get it's "value". It isn't a form control so it doesn't have a value
property. It has childNodes, the one of which you care about is another div.
var childDiv = div.querySelector('.text');
You can skip the two stages if you are are using querySelector and just use a descendant combinator:
var childDiv = document.querySelector('.question .text');
This child div then has another child node, but it is a text node rather than an element node. You can get it like so:
var textNode = div.firstChild;
Finally you can get the text in a textNode using the data
property.
var text = textNode.data;
And if you put it all together:
alert(document.querySelector('.question .text').firstChild.data);
Such: http://jsfiddle.net/LR93S/