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的形式发送到后台对象中,所有每 ...
随机推荐
- Lusac定理
转载大佬的模版:http://www.cnblogs.com/vongang/archive/2012/12/02/2798138.html
- 微信小程序从零开始开发步骤(五)轮播图
上一章完成页面自定义分享,这一章来说说轮播图,最常见的一个轮播图,中间带小圆点,自动轮播. Swiper是滑动特效插件,面向手机.平板电脑等移动终端.能实现触屏焦点图.触屏Tab切换.触屏多图切换等常 ...
- POJ——T 2752 Seek the Name, Seek the Fame
http://poj.org/problem?id=2752 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 20418 ...
- CodeForce 424C Magic Formulas
这个题就是求出给的公式的结果. 仅仅要知道异或运算满足交换律跟结合律即可了.之后就是化简公式. #include<map> #include<string> #include& ...
- Autodesk 招聘Revit二次开发咨询顾问,与Autodesk全球团队紧密合作,提高职业生涯的好机会
朋友们, 因为我离开Autodesk的全职工作(变为部分时间工作),我的职位空出.急招这个职位.请踊跃把你周围的朋友推荐给Autodesk. 请将简历发给我转交给Autodesk 我的邮箱yexion ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第9章节--client对象模型和REST APIs概览 托管代码(.NET)
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第9章节--client对象模型和REST APIs概览 托管代码(.NET) 在SP2010中,微软提 ...
- 新手前端笔记之--初识html标签
接触前端(好大气的名字啊)已经一个多月了,看了很多视频和博客,有了一定的感性认识,但还是需要总结一下以便系统化所学习的知识,就从html标签开始吧.关于标签,谈论最多的就是简洁和语义化.简洁指html ...
- map(froeach改变值,map生成新数组)
http://www.365mini.com/page/jquery-map.htm <input id="n1" name="uid" type=&qu ...
- Vue的style与class
1. style 可以通过 :style="{height:`${heightData.main}px`}" 实现样式的动态绑定, style绑定的是一个对象,多个样式时用“,”隔 ...
- Scala入门到精通——第二十九节 Scala数据库编程
本节主要内容 Scala Mavenproject的创建 Scala JDBC方式訪问MySQL Slick简单介绍 Slick数据库编程实战 SQL与Slick相互转换 本课程在多数内容是在官方教程 ...