jQuery實(shí)現(xiàn)表格文本框淡入更改值后淡出效果
本文分為html代碼和jquery兩段代碼,代碼很簡(jiǎn)單,大家可以參考下!
html代碼
<table style="border:1px solid blue"> <tr> <th>id</th> <th>name</th> <th>age</th> <th>sex</th> <th>操作</th> </tr> <tr> <td class="td1">1</td> <td class="td1">珠珠</td> <td class="td1">21</td> <td class="td1">女</td> <td class="td2"></td> </tr> <tr> <td class="td1">2</td> <td class="td1">琛琛</td> <td class="td1">18</td> <td class="td1">男</td> <td class="td2"></td> </tr> </table>
jquery代碼
<script> var a; $(document).ready(function () { $("td[class='td1']").click(function () { var tdlist = $(this).parent().children();//獲取td a = "<tr style='display:none'>"; tdlist.each(function (i) { var text = tdlist.eq(i).text(); if (tdlist.eq(i).html().indexOf("input") < 0&&tdlist.eq(i).html().indexOf("button")<0) { if (tdlist.length == (i + 1)) { a+="<td><button>確定</button></td>"; } else if (i==0) { a += "<td><input type='text' readonly='true' value='" + text + "'></td>"; } else { a+="<td><input type='text' value='"+text+"'></td>"; } } }); a += "</tr>"; $(this).parent().after(a).next().fadeIn("3000"); }); $(this).delegate("button", "click", function () { var list = $(this).parent().parent().children();//當(dāng)前td的值 var li = $(this).parent().parent();//當(dāng)前tr list.each(function (i) { var b = list.eq(i).children().eq(0).val();//當(dāng)前input的值 var shngjitd=li.prev().children();//上一級(jí)td if (list.length != (i+1)) { shngjitd.eq(i).text(b); li.fadeOut("3000"); } else { list.eq(i).text(""); } }); }); }); </script>
以上所述是小編給大家介紹的jQuery實(shí)現(xiàn)表格文本框淡入更改值后淡出效果,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
通過(guò)pjax實(shí)現(xiàn)無(wú)刷新翻頁(yè)(兼容新版jquery)
這篇文章主要介紹了通過(guò)pjax實(shí)現(xiàn)無(wú)刷新翻頁(yè),兼容新版jquery,使用心得方法,需要的朋友可以參考下2014-01-01jquery下拉select控件操作方法分享(jquery操作select)
這篇文章主要介紹了jquery下拉select控件操作方法分享(jquery操作select),需要的朋友可以參考下2014-03-03一個(gè)背景云變換js特效 鼠標(biāo)移動(dòng)背景云變化
分享一個(gè)背景云變換js特效隨著鼠標(biāo)的移動(dòng),背景云會(huì)不斷的變化位置和形狀,感興趣的朋友可以研究下2012-12-12自己使用jquery寫(xiě)的一個(gè)無(wú)縫滾動(dòng)的插件
這篇文章主要介紹的是自己使用jquery寫(xiě)的一個(gè)無(wú)縫滾動(dòng)的插件,個(gè)人感覺(jué)還不錯(cuò),需要的朋友可以參考下2014-04-04Ajax 數(shù)據(jù)請(qǐng)求的簡(jiǎn)單分析
Ajax使用的關(guān)鍵對(duì)象是XmlHttpRequest對(duì)象,但是涉及到跨瀏覽器的的問(wèn)題,所以,需要?jiǎng)?chuàng)建一個(gè)具兼容性的對(duì)象2011-04-04當(dāng)jQuery遭遇CoffeeScript的時(shí)候 使用分享
雖然對(duì)ruby不太了解,但是看到CoffeeScript詩(shī)一般的代碼確實(shí)被怔住了,和jQuery之前給我的感覺(jué)是如此的相似——都是一個(gè)字,美,當(dāng)jQuery遭遇到CoffeeScript時(shí),會(huì)蹦出什么樣的火花呢?2011-09-09jquery中防刷IP流量軟件影響統(tǒng)計(jì)的一點(diǎn)對(duì)策
由于公司項(xiàng)目需要增加推廣獎(jiǎng)勵(lì)功能,網(wǎng)站用戶通過(guò)邀請(qǐng)地址發(fā)給QQ好友、論壇、個(gè)人網(wǎng)站之類,只要有通過(guò)邀請(qǐng)地址點(diǎn)擊進(jìn)來(lái)就算推廣成功(當(dāng)天同一個(gè)IP僅算一次),推廣人會(huì)獲得相應(yīng)的獎(jiǎng)勵(lì)、積分等。2011-07-07jQuery實(shí)現(xiàn)的tab標(biāo)簽切換效果示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的tab標(biāo)簽切換效果,結(jié)合實(shí)例形式分析了jQuery響應(yīng)鼠標(biāo)事件動(dòng)態(tài)變換頁(yè)面元素屬性的相關(guān)操作技巧,需要的朋友可以參考下2016-09-09