這篇文章主要介紹了JavaScript怎么實(shí)現(xiàn)訂單操作小程序的相關(guān)知識(shí),內(nèi)容詳細(xì)易懂,操作簡(jiǎn)單快捷,具有一定借鑒價(jià)值,相信大家閱讀完這篇JavaScript怎么實(shí)現(xiàn)訂單操作小程序文章都會(huì)有所收獲,下面我們一起來(lái)看看吧。
讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來(lái)自于我們對(duì)這個(gè)行業(yè)的熱愛(ài)。我們立志把好的技術(shù)通過(guò)有效、簡(jiǎn)單的方式提供給客戶,將通過(guò)不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長(zhǎng)期合作伙伴,公司提供的服務(wù)項(xiàng)目有:國(guó)際域名空間、網(wǎng)頁(yè)空間、營(yíng)銷軟件、網(wǎng)站建設(shè)、舒蘭網(wǎng)站維護(hù)、網(wǎng)站推廣。
具體代碼如下
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <style> table { text-align: center; } </style> <script> function delRow(id) { //取得要?jiǎng)h除的那一行 var row = document.getElementById(id);//按照id來(lái)找到行 var table = document.getElementById('mytb'); table.deleteRow(row.rowIndex);//按照行的索引刪除某行的內(nèi)容 } function addrow() { var mytb = document.getElementById('mytb'); var index = mytb.rows.length - 1;//取得插入目標(biāo)索引,某行 var row = mytb.insertRow(index);//把行插入到某個(gè)位置,插入某行 var id = 'row' + row.rowIndex;//拼接id row.setAttribute('id', id);//設(shè)置id var td0 = row.insertCell(0);//td0創(chuàng)建一個(gè)單元格 td0.innerHTML = "好看耐用超耐磨沙發(fā)兩件套";//設(shè)置td0的內(nèi)容 var td1 = row.insertCell(1); td1.innerHTML = row.rowIndex;//把行的索引賦給td1的內(nèi)容 var td2 = row.insertCell(2);//把td2插入在某個(gè)單元格里面 td2.innerHTML = '<input type="button" value="刪除" onclick="delRow(\'' + id + '\')">' + '<input type="button" value="修改" id="update" onclick="update(\'' + id + '\')">'; } function update(id) { var row = document.getElementById(id); var td1 = row.cells[1]; var v = td1.innerHTML; td1.innerHTML = '<input type="text" value="' + v + '">'; row.cells[2].innerHTML = '<input type="button" value="刪除" onclick="delRow(\'' + id + '\')">' + '<input type="button" value="確定" id="update" onclick="comfirmrow(\'' + id + '\')">'; } function comfirmrow(id) { var row=document.getElementById(id); var td1=row.cells[1];//取得各行的第二個(gè)單元格 var input=td1.firstChild;//取得input標(biāo)簽 var v=input.value;//取得input的內(nèi)容 td1.innerHTML=v;//把內(nèi)容賦給td1 var td2=row.cells[2]; td2.innerHTML = '<input type="button" value="刪除" onclick="delRow(\'' + id + '\')">' + '<input type="button" value="修改" id="update" onclick="update(\'' + id + '\')">'; } </script> </head> <body> <table border="1" cellspacing="0" cellpadding="0" id="mytb"> <tr> <td>商品名</td> <td>數(shù)量</td> <td>操作</td> </tr> <tr id="del1"> <td>好看耐用超耐磨沙發(fā)兩件套</td> <td>24</td> <td><input type="button" value="刪除" onclick="delRow('del1')"><input type="button" value="修改"></td> </tr> <tr> <td colspan="3"><input type="button" value="增加訂單" onclick="addrow()"></td> </tr> </table> </body> </html>
關(guān)于“JavaScript怎么實(shí)現(xiàn)訂單操作小程序”這篇文章的內(nèi)容就介紹到這里,感謝各位的閱讀!相信大家對(duì)“JavaScript怎么實(shí)現(xiàn)訂單操作小程序”知識(shí)都有一定的了解,大家如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
分享名稱:JavaScript怎么實(shí)現(xiàn)訂單操作小程序
網(wǎng)站路徑:http://vcdvsql.cn/article4/jhgooe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、商城網(wǎng)站、網(wǎng)站設(shè)計(jì)、、響應(yīng)式網(wǎng)站、Google
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)