我的: class CountInfo { constructor() { let tfoot = document.getElementsByTagName("tfoot")[0] let countInfoTag = tfoot.children[0].children[1] let tmp = countInfoTag.innerHTML.match(/\d+/g) let countInfo = { price: 0, num: 0 } countInfo.price = (tmp[0] - 0) + (tmp[1] - 0) * 0.01 countInfo.num = tmp[2] - 0 this.countInfoTag = countInfoTag this.countInfo = countInfo } delete(price) { this.countInfo.num-- this.countInfo.price = this.countInfo.price - price this.countInfoTag.innerHTML = `${this.countInfo.price.toFixed(2)}(${this.countInfo.num}件商品)` } add(price) { this.countInfo.num++ this.countInfo.price = this.countInfo.price + price this.countInfoTag.innerHTML = `${this.countInfo.price.toFixed(2)}(${this.countInfo.num}件商品)` } } bind() function add(items) { let tr = document.createElement("tr") tr.innerHTML = `<td>${items.name}</td><td>${items.price.toFixed(2)}</td><td><a href="javascript:void(0);">删除</a></td>` let tbody = document.getElementsByTagName("tbody")[0] tbody.appendChild(tr) tr.children[2].children[0].onclick = click const countInfo = new CountInfo() countInfo.add(items.price) } function bind() { let tags = document.getElementsByTagName("a") const LEN = tags.length for (let i = 0; i < LEN; i++) { tags[i].onclick = click } } function click(e) { const countInfo = new CountInfo() let tr = e.srcElement.parentElement.parentElement countInfo.delete(tr.children[1].innerHTML - 0) tr.remove() }
点赞 1

相关推荐

昨天 15:08
门头沟学院 Java
春招第一枪拷打实习挑一个项目介绍一下手撕归并排序
滴滴滴d:我昨天也面了,感觉答得还行,结果秒挂
查看2道真题和解析
点赞 评论 收藏
分享
02-22 18:38
门头沟学院 Java
程序员牛肉:标准的NPC简历,一个短链接+12306。你可以在牛客上面搜一搜有多少人的简历和你一样。你自己能不能给出你一个理由让面试官在大家简历高度相同的情况下,选择约面你而不是对应的211,985学生? 是因为你即将拥有的那段小厂实习吗?这种小厂实习真的很有含金量吗?因此你可以找实习,但是你如果只能找到小厂实习的话,其实意义不太大。 但你的时间是充足的,相信我:从现在到今年的九月份大三上你就干两个事情:"写博客"+“参加开源之夏”。这两个搞好了不亚于一段大厂实习的含金量。 想要让自己变得更强,首先就是不要把自己当打工人看待,让自己简历上面的活人气息更多一点,不要让自己成为流水线的产物。你不是在出售你的技能,你是在利用你的技能和公司达成一种合作关系。
点赞 评论 收藏
分享
牛客网
牛客企业服务