jquery如何实现动态增加选择框
jquery如何实现动态增加选择框
一、总结
一句话总结:用jquery的clone(true)方法。
1、如何在页面中复制amazeui加了特效的标签?
amazeui中的控件带js方法,不知道那部分js的情况下,只有不用功能才能方便用clone(true)复制
2、选兄弟选不到的时候怎么选元素?
通过父亲选儿子,照样可以达到相同的功能
3、表单中的控件如何让它不能提交过去?
控件设置为disabled
二、jquery如何实现动态增加选择框

<script>
function taskRewardHidden(){
$('div.goods').hide();
$('div.goods').find($('select')).attr({'disabled':'disabled'});
$('div.attribute').hide();
$('div.attribute').find($('select')).attr({'disabled':'disabled'});
}
taskRewardHidden();
$('div.attribute').show();
$('div.attribute').find($('select')).removeAttr('disabled'); //把作为复制之用的那个item的所有东西都设置为disabled,避免提交
//$('.task_reward_list_item:first').find($('select,input[type=number]')).attr({'disabled':'disabled'}); $('div.reward_type').children("select").change(function () {
//$(this)就有选出来的就有问题
var type=$(this).val();
//alert($(this).html());
//alert($(this).parent().parent().children('.goods').html());
$(this).parent().parent().children('.goods').hide();
$(this).parent().parent().children('.goods').find($('select')).attr({'disabled':'disabled'});
$(this).parent().parent().children('.attribute').hide();
$(this).parent().parent().children('.attribute').find($('select')).attr({'disabled':'disabled'});
$(this).parent().parent().children('.'+type).show();
$(this).parent().parent().children('.'+type).find($('select')).removeAttr('disabled'); //taskRewardHidden();
//$('div.'+type).show();
}); //增加一个隐藏的task_reward_list_item做复制之用
$('.task_btn_addReward').click(function () {
//把作为复制之用的那个item的所有东西都设置的disabled移去,方便复制
$('.task_reward_list_item:first').find($('select,input[type=number]')).removeAttr('disabled');
//复制过来的东西因为只显示了属性,所以还要把物品设置成disabled
$('.task_reward_list_item:first').find($('div.goods').find($('select'))).attr({'disabled':'disabled'});
//复制
var new_task_reward_list_item=$('.task_reward_list_item:first').clone(true); //var new_task_reward_list_item=$('.task_reward_list_item:first').find($('select,input[type=number]')).removeAttr('disabled').end().clone(true);
//显示
new_task_reward_list_item.show().animate({
'top': '-500px', opacity: '0.5'
}, 1);
$('div.task_reward_list_group').animate({
borderWidth: 15
},10);
new_task_reward_list_item.animate({
'top': '0', opacity: '1'
}, 500,'swing');
//alert($('div.task_reward_list_group').length);
$('div.task_reward_list_group').css({
'border-bottom': '5px groove'
});
$('div.task_reward_list_group').animate({
borderWidth: 15
},499);
$('div.task_reward_list_group').animate({
borderWidth: 7
},1);
new_task_reward_list_item.animate({
'top': '-130px', opacity: '1'
}, 200,'linear');
new_task_reward_list_item.animate({
'top': '0', opacity: '1'
}, 200,'linear');
$('div.task_reward_list_group').animate({
borderWidth: 7
},399);
$('div.task_reward_list_group').animate({
borderWidth: 3
},1);
new_task_reward_list_item.animate({
'top': '-65px', opacity: '1'
}, 200,'linear');
new_task_reward_list_item.animate({
'top': '0', opacity: '1'
}, 200,'linear');
$('div.task_reward_list_group').animate({
borderWidth: 3
},399);
$('div.task_reward_list_group').animate({
borderWidth: 1.5
},1);
new_task_reward_list_item.animate({
'top': '-30px', opacity: '1'
}, 200,'linear');
new_task_reward_list_item.animate({
'top': '0', opacity: '1'
}, 200,'linear');
$('div.task_reward_list_group').animate({
borderWidth: 1.5
},399);
$('div.task_reward_list_group').animate({
borderWidth: 0
},1); //alert($('.task_reward_list_item:first').find($('select,input[type=number]')).length);
//alert(new_task_reward_list_item.html());
//alert(new_task_reward_list_item.html());
$('.task_reward_list_group').append(new_task_reward_list_item);
//把作为复制之用的那个item的所有东西都设置为disabled,避免提交
$('.task_reward_list_item:first').find($('select,input[type=number]')).attr({'disabled':'disabled'}); //把第一个奖励列表数据拿来用用
}); //关闭方法 $('.task_reward_list_item_close').click(function () {
//alert($('.task_reward_list_item_close').length);
//alert($('.task_reward_list_item_close').eq(0));
//alert($(this).parent().index());
//找出它的索引号,判断索引号是不是0来解决
//比较用数字来比较比较好
if($(this).parent().index()==1) alert('第一个不能删!');
else{
$(this).parent().hide();
//alert($(this).parent().find($('select,input[type=number]')).length);
$(this).parent().find($('select,input[type=number]')).attr({'disabled':'disabled'});
}
//隐藏的元素不让传参数
}); //执行js的时候,php早走完了,所以选项只有一份,当时可以通过dom把数据弄过来
//以为这里涉及到amaze ui里面的js,所以会出错
//不用amaze ui的这个选择框特效就特别好做了 </script>
jquery如何实现动态增加选择框的更多相关文章
- 基于jQuery美化联动下拉选择框
今天给大家介绍一款基于jQuery美化联动下拉选择框.这款下下拉选择框js里自带了全国所有城市的数数库.下拉选择框适用浏览器:IE8.360.FireFox.Chrome.Safari.Opera.傲 ...
- jquery.chosen.js下拉选择框美化插件项目实例
由于之前使用的bootstrap-select插件是建立在bootstrap基础上的,实际使用到项目中的时候,与我们使用的ace-admin(基于bootstrap)存在样式冲突,导致下拉框的样式发生 ...
- jquery中为动态增加的元素添加事件
// html代码 <ul id="main"> </ul> // js代码 $(function(){ // 动态添加html代码 $("#ma ...
- [jQuery编程挑战]004 针对选择框词典式排序
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="utf-8&quo ...
- EasyUI combobox动态增加选择项
有需求需要动态的为combobox增加可选项,后来解决方案如下 html如下 <select id="workerList"></select> js 如下 ...
- jQuery立体式数字动态增加(animate方法)
1.HTML结构 <div class="integral">已有<span class="ii"></span>积分< ...
- 用jquery来实现正反选选择框checkbox的小示例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 转:zTree树控件入门之checkbox:如何动态设置节点的checkbox选择框启用与禁用状态(chkDisabled)
当一棵树的部分节点根据登入用户角色不同而决定是否启用节点前的checkbox选择框的时候,我们应该如何做呢?也或者如何在页面加载的时候动态根据当前登入用户角色动态切换节点前的checkbox的禁用状态 ...
- jquery动态增加或删除tr和td【实际项目】
难点: (1)动态增加.删除tr和td (2)每天tr和td都有下标,且下标要动态变化, (3)tr和td为什么下标不能随便写,原因是此处需要把所有tr中的数据以list的形式发送到后台对象中,所有每 ...
随机推荐
- 一起talk C栗子吧(第三十四回:C语言实例--巧用溢出计算最值)
各位看官们.大家好,上一回中咱们说的是巧用移位的样例,这一回咱们说的样例是:巧用溢出计算最值. 闲话休提,言归正转.让我们一起talk C栗子吧! 大家都知道,程序中的变量都有一个取值范围,这个范围也 ...
- ContentValues的使用
什么是 ContentValues类? ContentValues类和 Hashtable比较类似,它也是负责存储一些名值对,但是它存储的名值对当中的名是一个String类型,而值都是基本类型. 插入 ...
- excel表如何实现多if选择结构多分支判断
excel表如何实现多if选择结构多分支判断 一.总结 一句话总结:把多if分支转换成单if分支相加. 也可以if分支,也可以lookup函数. 1.CHOICE: +2 if band A; +1 ...
- while 循环的理解
if 与 while 的主要区别:if 只判断和执行一次,而 while 却代表着一个循环,执行多少次,要视情况而定: 两种情况(A.B)都会让循环体执行: while A or B: 两种情况(A. ...
- Hp Open View安装使用视频
去年完成的cisco works 2000操作(http://chenguang.blog.51cto.com/blog/350944/124729)视频深受广大博友欢迎许多人来信咨询,最近刚做完一个 ...
- CSS笔记 - SVG Polyline 图片绘制动画边框
<style> div{ width: 420px; height: 200px; background: url('./img/timg.jpg') no-repeat; } polyl ...
- STL中erase()的陷阱
最近在刷stl源码剖析这本书时,对于vector的erase()函数引起了我的注意 在删除单个元素时是这样定义的: iterator erase(iterator position){ !=end() ...
- 题目1205:N阶楼梯上楼问题(2008年华中科技大学计算机保研机试真题:递推求解)
题目1205:N阶楼梯上楼问题 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:2447 解决:927 题目描写叙述: N阶楼梯上楼问题:一次能够走两阶或一阶,问有多少种上楼方式. (要求 ...
- [转载]Google Java Style 中文版
转自:http://www.blogjava.net/zh-weir/archive/2014/02/08/409608.html Google Java Style 中文版 基于官方文档20 ...
- AndroidStudio MAT LeakCanary 内存分析之 LeakCanary
现在我们换一种更清晰方便的方式:LeakCanary https://github.com/square/leakcanary 首先将LeakCanary绑在我们的app上 build.gradle ...