Javascript examples for DOM HTML Element:Span
The Span object represents an HTML <span> element.
You can access a <span> element by using getElementById():
<!DOCTYPE html> <html> <body> <span id="mySpan" style="color:blue;">blue</span <button onclick="myFunction()">get the color of the span element</button> <p id="demo"></p> <script> function myFunction() {// w ww .j a v a2 s. c o m var x = document.getElementById("mySpan").style.color; document.getElementById("demo").innerHTML = x; } </script> </body> </html>