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

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 thought on “How to send the contents of a to a Javascript variable?

  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;