jq demo 点击选中元素左右移动

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>无标题文档</title>
<style>
#ul1 , #ul2{ width:200px; height:200px; border:1px #000 solid; float:left;}
li{ cursor:pointer;}
.active{ background:red;}
input{ float:left; margin-top:100px;}
</style>
<script src="jquery-1.11.1.js"></script>
<script>
$(function(){
	$('li').click(function(){
		$(this).toggleClass('active');
	});
	$('input').click(function(){
		var $formDom = $($(this).attr('form')).find('li[class=active]').css('color','green');
		$formDom.appendTo($($(this).attr('to')));
		$($(this).attr('to')).find('li[class=active]').removeClass('active');
	})
});  
</script>
</head>
<body>
<ul id="ul1">
	<li>1111</li>
    <li>2222</li>
    <li>3333</li>
    <li>4444</li>
    <li>5555</li>
</ul>
<input type="button" value="→" form='#ul1' to='#ul2' >
<input type="button" value="←" form='#ul2' to='#ul1'>
<ul id="ul2">
	<li>aaaa</li>
    <li>bbbb</li>
    <li>cccc</li>
    <li>dddd</li>
    <li>eeee</li>
</ul>
</body>
</html>

  

转载于:https://www.cnblogs.com/xwnlh/p/7058703.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值