javascript - Why does null keep coming back when getting nodeValue even though it displays properly? -


This is driving me crazy I'm going to insert code into a page via Ajax code after I put a Running a function to capture the text of the div and am displaying it on the page in another place.

Can anyone tell me why I am saying a javascript error that current text is zero, even if the text is displayed properly in the second place in the page ??

  var currentText = document.getElementById ("current-text"), updated text = Document.getElementById ("update-text-here"); UpdatedTextHere.innerHTML = currentText.firstChild.nodeValue;   

This is the code that is receiving text value, which is inserted through Ajax in the main page:

   

How it looks:

  getDate = function {var currentText = document.getElementById (" Current -text "), updated text = document. GetElementById (" update-text-here "); UpdatedTextHere.innerHTML = currentText.firstChild.nodeValue; }, Htmlready = function () {myDiv.innerHTML = xmlRequest.responseText; get Date(); },    

The problem you have is that firstChild This is not a node of currentText . Your nodeValue is not a value because it does not exist, instead you should use the innerHTML or textContent .

Change ...

  updatedTextHere.innerHTML = currentText. FirstChild.textContent; // or internal HTML    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -