我的回显包含javascript变量不起作用

雅像爵士

我有这段代码,它应该可以正常工作并回显该东西,但它不会

<!DOCTYPE html>
<html>
  <body>
      <div id="colo" style='color:rgb(24, 209, 95)'>Yeet</div>
      <div id="color"></div>
      <button onclick="color();" style='width:100px; height: 75px;'></button>
    <script type="text/javascript"> 

      function color(){
        var rgb = document.getElementById("colo").style.color; 
        document.getElementById("color").innerHTML = rgb;
      }  
    <?php $abc = "<script>document.write(rgb)</script>"?>   

      </script>


<?php echo $abc;?>



  </body>
</html>

我尝试将变量设置为不同但没有

康纳·布朗

这个对我有用。您同时使用PHP和JS,因此请确保您正在php服务器上运行此程序,因为它将无法在html文件中运行。

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章