How to put value of paragraph into JavaScript variable in an AJAX function.?

Bill S

New member
Say I have a paragraph in a div:
<div id="div1">
<p id="para1">10</p>
</div>
now, I should be able to call in a JavaScript function:
var ptext = document.getElementById('para1');
var text = ptext.innerHTML;
but it's not working and as a result my whole function stops. What am I doing wrong?
 
It should work... in this case I think innerText should get you the same thing. What OS and browser are you using? Try getting a debugger, it'd be quite useful. I use Visual Studio but only because I'm also doing ASP.NET, and it handles JavaScript as well. But there are many other, more lightweight JS-specific debuggers out there.
 
Back
Top