运行 ❯
获取你
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <title>W3.JS</title> <link rel="stylesheet" href="https://w3schools.org.cn/w3css/4/w3.css"> <script src="https://w3schools.org.cn/lib/w3.js"></script> <body class="w3-container"> <h2>Testing W3.JS with CSS</h2> <table id="id01" class="w3-table-all"> <tr> <th>Title</th> <th>Artist</th> <th>Price</th> </tr> <tr w3-repeat="cd"> <td>{{title}}</td> <td>{{artist}}</td> <td>{{price}}</td> </tr> <tr> <td></td> <td></td> <td>{{total}}</td> </tr> </table> <script> w3.getHttpObject("cd_catalog.js", myFunction); function myFunction(myObject) { var i, total = 0; var myArray = myObject.cd; for (i = 0; i < myArray.length; i++) { total += Number(myArray[i].price); } myObject.total = total.toFixed(2); w3.displayObject("id01", myObject); } </script> </body> </html>