Javascript variable access in HTML

后端 未结 7 1316
余生分开走
余生分开走 2020-12-13 09:44

Say I have the following JavaScript in a HTML page




        
相关标签:
7条回答
  • 2020-12-13 10:46

    It is also possible to use span tag instead of a tag:

    <html>
    <script>
       var simpleText = "hello_world";
       var finalSplitText = simpleText.split("_");
       var splitText = finalSplitText[0];
    
       document.getElementById('someId').InnerHTML = splitText;
    </script>
    
     <body>
      <span id="someId"></span>
     </body>
    
    </html>
    

    It worked well for me

    0 讨论(0)
提交回复
热议问题