jQuery實(shí)現(xiàn)表格文本框淡入更改值后淡出效果
本文分為html代碼和jquery兩段代碼,代碼很簡單,大家可以參考下!
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();//上一級td
if (list.length != (i+1)) {
shngjitd.eq(i).text(b);
li.fadeOut("3000");
}
else {
list.eq(i).text("");
}
});
});
});
</script>
以上所述是小編給大家介紹的jQuery實(shí)現(xiàn)表格文本框淡入更改值后淡出效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
通過pjax實(shí)現(xiàn)無刷新翻頁(兼容新版jquery)
這篇文章主要介紹了通過pjax實(shí)現(xiàn)無刷新翻頁,兼容新版jquery,使用心得方法,需要的朋友可以參考下2014-01-01
jquery下拉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寫的一個(gè)無縫滾動(dòng)的插件
這篇文章主要介紹的是自己使用jquery寫的一個(gè)無縫滾動(dòng)的插件,個(gè)人感覺還不錯(cuò),需要的朋友可以參考下2014-04-04
當(dāng)jQuery遭遇CoffeeScript的時(shí)候 使用分享
雖然對ruby不太了解,但是看到CoffeeScript詩一般的代碼確實(shí)被怔住了,和jQuery之前給我的感覺是如此的相似——都是一個(gè)字,美,當(dāng)jQuery遭遇到CoffeeScript時(shí),會(huì)蹦出什么樣的火花呢?2011-09-09
jquery中防刷IP流量軟件影響統(tǒng)計(jì)的一點(diǎn)對策
由于公司項(xiàng)目需要增加推廣獎(jiǎng)勵(lì)功能,網(wǎng)站用戶通過邀請地址發(fā)給QQ好友、論壇、個(gè)人網(wǎng)站之類,只要有通過邀請地址點(diǎn)擊進(jìn)來就算推廣成功(當(dāng)天同一個(gè)IP僅算一次),推廣人會(huì)獲得相應(yīng)的獎(jiǎng)勵(lì)、積分等。2011-07-07
jQuery實(shí)現(xiàn)的tab標(biāo)簽切換效果示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的tab標(biāo)簽切換效果,結(jié)合實(shí)例形式分析了jQuery響應(yīng)鼠標(biāo)事件動(dòng)態(tài)變換頁面元素屬性的相關(guān)操作技巧,需要的朋友可以參考下2016-09-09

