酷代码 AI
菜单
服务商

品牌列表制作 作业要求: 1、使用原生js配合ecma的高级语法实现,不可以直接使用vue实现。(练习js和ecma) 2、点击添加功能可以在表格下面新增加一行 3、点击删除会出现确认框,如果点击确认就移除对应的这一行。 4、表格中时间的处理可以使用原生js,也可以根据提供的素材lib文件夹中的dayjs来实现。

以下是一个使用原生 JavaScript 和 ECMAScript 高级语法实现的品牌列表制作示例,包含添加和删除行的功能: ```html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>品牌列表</title> </head> <body> <h1>品牌列表</h1> <table id="brandTable"> <tr> <th>品牌名称</th> <th>创立时间</th> <th>操作</th> </tr> </table> <button onclick="addBrand()">添加</button> <script src="https://unpkg.com/dayjs@1.11.7/dayjs.min.js"></script> <script> function addBrand() { const table = document.getElementById('brandTable'); const newRow = table.insertRow(-1); const brandNameCell = newRow.insertCell(0); const createTimeCell = newRow.insertCell(1); const operationCell = newRow.insertCell(2); const brandNameInput = document.createElement('input'); brandNameCell.appendChild(brandNameInput); const createTimeInput = document.createElement('input'); createTimeCell.appendChild(createTimeInput); const deleteButton = document.createElement('button'); deleteButton.textContent = '删除'; deleteButton.addEventListener('click', function () { if (confirm('确定要删除这一行吗?')) { table.deleteRow(newRow.rowIndex); } }); operationCell.appendChild(deleteButton); } </script> </body> </html> ``` 在上述代码中,点击"添加"按钮会在表格中新增一行,包含品牌名称、创立时间的输入框和删除按钮。点击删除按钮会弹出确认框,确认后删除对应行。 [2024-11-17 21:59:01 | AI写代码神器 | 469点数解答]

相关提问
实用工具查看更多
今日油价 [生活类]
图片互转base64 [开发类]
时间转换器 [开发类]
数独游戏 [娱乐类]
经典推箱子 [娱乐类]
AI摸鱼五子棋 [娱乐类]