jQuery监听事件经典例子
2024-08-31 09:42:32
关键字:jQuery监听事件经典例子
js代码:
============================================================
$(function(){
$("#s1 option:first,#s2 option:first").attr("selected",true);
$("#s1").dblclick(function(){
var alloptions = $("#s1 option");
var so = $("#s1 option:selected");
so.get(so.length-1).index == alloptions.length-1?so.prev().attr("selected",true):so.next().attr("selected",true);
$("#s2").append(so);
});
$("#s2").dblclick(function(){
var alloptions = $("#s2 option");
var so = $("#s2 option:selected");
so.get(so.length-1).index == alloptions.length-1?so.prev().attr("selected",true):so.next().attr("selected",true);
$("#s1").append(so);
});
$("#add").click(function(){
var alloptions = $("#s1 option");
var so = $("#s1 option:selected");
so.get(so.length-1).index == alloptions.length-1?so.prev().attr("selected",true):so.next().attr("selected",true);
$("#s2").append(so);
});
$("#remove").click(function(){
var alloptions = $("#s2 option");
var so = $("#s2 option:selected");
so.get(so.length-1).index == alloptions.length-1?so.prev().attr("selected",true):so.next().attr("selected",true);
$("#s1").append(so);
});
$("#addall").click(function(){
$("#s2").append($("#s1 option").attr("selected",true));
});
$("#removeall").click(function(){
$("#s1").append($("#s2 option").attr("selected",true));
});
$("#s1up").click(function(){
var so = $("#s1 option:selected");
if(so.get(0).index!=0){
so.each(function(){
$(this).prev().before($(this));
});
}
});
$("#s1down").click(function(){
var alloptions = $("#s1 option");
var so = $("#s1 option:selected");
if(so.get(so.length-1).index!=alloptions.length-1){
for(i=so.length-1;i>=0;i--)
{
var item = $(so.get(i));
item.insertAfter(item.next());
}
}
});
$("#s2up").click(function(){
var so = $("#s2 option:selected");
if(so.get(0).index!=0){
so.each(function(){
$(this).prev().before($(this));
});
}
});
$("#s2down").click(function(){
var alloptions = $("#s2 option");
var so = $("#s2 option:selected");
if(so.get(so.length-1).index!=alloptions.length-1){
for(i=so.length-1;i>=0;i--)
{
var item = $(so.get(i));
item.insertAfter(item.next());
}
}
});
});
最新文章
- mybatis generator.xml 配置 自动生成model,dao,mapping
- (一)洞悉linux下的Netfilter&;iptables:什么是Netfilter?
- easyui 》 radio取值,checkbox取值,select取值,radio选中,checkbox选中,select选中
- python中常用的函数与库一
- Can't bind to local 8700 for debugger报错和解决
- java 动态代理范例 InvocationHandler与Proxy
- 随意一条查询sql转换为查询结果集相应的数目
- tomcat中jsp编译
- NEC遥控信号解码(包含完整代码)
- jquery获取复选框
- C. Bits (Codeforces Round #276 (Div. 2) )
- 胡na娜、少年和恩师-写在甲午冬的仅仅言片语及感想
- iOS使用自定义字体的方法(内置和任意下载ttf\otf\ttc字体文件)
- .NET 自定义Json序列化时间格式
- Builder模式的思考(Effective Java)
- opencron
- Unity3D UGUI实现Toast
- Linux内核期末总结
- pdfcrop不能使用
- 用ADO操作数据库的方法步骤(ZT)