I have some text within my span tag, and I’d like to retreive the text with javascript, I tried using data, or nodeValue, but i kept getting a empty string alert.
here’s the html:
[code]
<div id=”container” class=”wrapper”>
<div style=”position:absolute; left:15px; top:100px;” onmousedown=”beginDrag(this, event);”>
<span class=”fieldValue” title=”one”>blah blah blah 1</span>
</div>
</div>
and here’s my js:
[code]
function beginDrag(elementToDrag, event) {
//i omitted all unrelated of the functions within beginDrag
//given somewhere within beginDrag, addToTargetContainer is being called..
function addToTargetContainer(){
var textNode = elementToDrag.firstChild;
alert(textNode.data); //this shows empty string
alert(textNode.nodeValue); //this also shows empty string
alert(textNode.nodeName); //this shows #text
}
}//end beginDrag
it sure did recongize my span tag as a #text tag, and it won’t show my text value within it, i think i must overlooked something very simple,
thank you for ur help