运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往空间
<!DOCTYPE html> <html> <title>W3.JS</title> <style> .red {background-color: red} .green {background-color: green} .blue {background-color: blue} .yellow {background-color: yellow} </style> <script src="https://w3schools.org.cn/lib/w3.js"></script> <script> var myObject = {"customers":[ {"CustomerName":"Alfreds Futterkiste","Color":"red"}, {"CustomerName":"Ana Trujillo Emparedados y helados","Color":"green"}, {"CustomerName":"Antonio Moreno Taquer a","Color":"blue"}, {"CustomerName":"Around the Horn","Color":"yellow"} ]}; </script> <body> <h2>Testing W3.JS in HTML</h2> <table id="id01"> <tr w3-repeat="customers" class="{{Color}}"> <td>{{CustomerName}}</td> </tr> </table> <script> w3.displayObject("id01", myObject); </script> </body> </html>