宝哥软件园

单击jQuery显示表单的颜色更改、全选和删除

编辑:宝哥软件园 来源:互联网 时间:2021-09-06

看了一下书上的代码,打了一会,发现优化后的代码比书上的更简单,功能更强,就贴出来保存起来,以后用。

功能:

单击以更改背景颜色,选择删除,选择全部删除,并在表格行中显示原始图片

效果显示:

代码粘贴:

html头元http-equiv=' Content-Type ' Content=' text/html;charset=utf-8 '/title/title meta name=' keywords ' content=' keywords '/meta name=' description ' content=' description '/head script type=' text/JavaScript ' src=' http : jquery-1。7 .2 .量滴js '/script style type=' text/CSS ' body { font-size :12 px } table { width :360 px;边框-折叠:折叠}表格tr th,TD { border : solid 1px # 666 text-align : center }表格tr TD img { border : solid 1px # CCC;padding:3px宽度:42 px高度:60 px光标:指针}表tr TD span { float : leftadd-left :12 px }表格tr th {底色: # CCC高度:32px背景-color:#fff} .clsImg { position : absoluteborder : solid 1px # cccpadding :3 px背景色: # eeedisplay : none cursor : pointer } .BTN { border : solid 1px # 666 padd :2 px宽度:50 px过滤器: progd : maximagettransform .微软。渐变(渐变类型=0,StartColorStr=# fff,endcolorst=# ece9d 8);光标:指针}/样式正文脚本类型=' text/JavaScript ' $(function(){//点击表格行变色$('tr ').单击(function(){ if()(this。风格。背景色=' ')| | |(这个。风格。背景色==' RGB(255,255,255)')){这个。风格。CSS文本='底色: # CCC ';} else { this。风格。CSS文本='底色: # fff ';} }) //放大图显示$('.a ').鼠标移动(函数(e){ $('#imgTip ').显示()。attr('src ',这个。src);$('#imgTip ').css({'top':(e.pageY 5) 'px ',' left ' :(e . Pagex 5)' px ' });});$('.a ').鼠标悬停(函数(e){ $('#imgTip ').显示()。attr('src ',这个。src);$('#imgTip ').css({'top':(e.pageY 5) 'px ',' left ' :(e . Pagex 5)' px ' });});$('.a ').mouseout(function(){ $('#imgTip ')).hide();});//点击全选$('#checkAll ').单击(function(){ if(this。选中){ $(' :复选框').attr('checked ',true);}else{ $(':checkbox ').attr('checked ',false);} });//删除部分与全部$('.BTN ' .单击(函数(){ if($('#checkAll ')).attr('选中'){ $('表tr TD :复选框:不'(# CheckAll ')').每个(函数(索引){ $(“#”this . value).移除();});} else { $(' :复选框:非'(# CheckAll ')').每个(函数(索引){如果(这个。选中了){ $(' # '这个。值).移除();} }) } });});/scripttable tr th选项/th编号/th封面/th购书人/th性别/th够书价/th/tr tr id=' 0 ' t输入类型=' checkbox '名称=' id=' checkbox 1 '值=' 0 '/TD TD TD 1001/TD tdimg src=' http :1。jpg ' title=' alt=' class=' a '/TD李小明运输署/运输署男TD/TD/35.6元/TD/tr tr id=' 1 ' TD输入类型=' checkbox '名称=' id=' checkbox 2 '值=' 1 '/TD TD TD 1002/TD tdimg src=' http :2。jpg ' title=' alt=' class=' a '/TD王明运输署/运输署男TD/TD/28.9元/TD/tr tr id=' 2 ' TD输入类型=' checkbox '名称=' id=' checkbox 3 '值=' 2 '/TD TD TD 1003/TD tdimg src=' http :3。jpg ' title=' alt=' class=' a '/TD皮特运输署/运输署女TD/TD/34.3元/TD/tr tr id=' 3 ' t输入类型=' checkbox '名称=' id=' checkbox 3 '值=' 3 '/TD TD TD 2356/TD tdimg src=' http :4。jpg ' title=' alt=' class=' a '/TD爱丁堡运输署/运输署男TD/TD/23.3元/TD/tr/tabletable tr TD style=' text-align : left;高度:28 px ' span put type=' checkbox ' name=' id=' CheckAll '/全选/span span put type=' button ' value='删除' BTN '/span/TD/tr/tableimg src=' http :1。jpg ' title=' alt=' id=' imgTip ' class=' Clsimg '/body/html以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

更多资讯
游戏推荐
更多+