How to send the contents of a to a Javascript variable?

Dec 7th, 2009 | By KC | Category: JavaScript Related

Basically, we have a following <SPAN> that is filled with a PHP function, though we need to squeeze a essence with Javascript. Here is a SPAN:

<span id="maxenergy">1442</span>

I need to feed that worth to a Javascript non-static that we can make use of after in a script.

Any assistance appreciated.

One comment
Leave a comment »

  1. Use document.getElementById() to find the span, then get the content of that span from its innerHTML property. Like this:

      var spanContent = document.getElementById("maxenergy").innerHTML;

Leave Comment