使用jQuery插件实现简单购物
2012-03-21 22:08
585 查看
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="_3._21拖拽购物车.WebForm2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
h1 { padding: .2em; margin: 0; }
#products { float:left; width: 500px; margin-right: 2em; }
#cart { width: 200px; float: left; }
/* style the list to maximize the droppable hitarea */
#cart ol { margin: 0; padding: 1em 0 1em 3em; }
</style>
<script src="js/Jquery1.7.js" type="text/javascript"></script>
<script src="js/jquery.ui.core.js" type="text/javascript"></script>
<script src="js/jquery.ui.widget.js" type="text/javascript"></script>
<script src="js/jquery.ui.mouse.js" type="text/javascript"></script>
<script src="js/jquery.ui.draggable.js" type="text/javascript"></script>
<script src="js/jquery.ui.droppable.js" type="text/javascript"></script>
<script src="js/jquery.ui.sortable.js" type="text/javascript"></script>
<script src="js/jquery.ui.accordion.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#catalog").accordion();
$("#catalog li").draggable({
appendTo: "body",
helper: "clone"
});
$("#cart ol").droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function (event, ui) {
$(this).find(".placeholder").remove();
$("<li></li>").text(ui.draggable.text()).appendTo(this);
}
}).sortable({
items: "li:not(.placeholder)",
sort: function ();
$(this).removeClass("ui-state-default");
}
});
});
</script>
</head>
<body>
<div class="demo">
<div id="products">
<h1 class="ui-widget-header">产品</h1>
<div id="catalog">
<h3><a href="#">家电用具</a></h3>
<div>
<ul>
<li>空调</li>
<li>冰箱</li>
<li>电脑</li>
</ul>
</div>
<h3><a href="#">衣服</a></h3>
<div>
<ul>
<li>鞋子</li>
<li>风衣</li>
<li>裤子</li>
</ul>
</div>
<h3><a href="#">学习用品</a></h3>
<div>
<ul>
<li>钢笔</li>
<li>橡皮</li>
<li>铅笔</li>
</ul>
</div>
</div>
</div>
<div id="cart">
<h1 class="ui-widget-header">购物车</h1>
<div class="ui-widget-content">
<ol>
<li class="placeholder">Add your items here</li>
</ol>
</div>
</div>
</div>
<div class="demo-description">
<p>快乐购物,,欢乐你我</p>
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
h1 { padding: .2em; margin: 0; }
#products { float:left; width: 500px; margin-right: 2em; }
#cart { width: 200px; float: left; }
/* style the list to maximize the droppable hitarea */
#cart ol { margin: 0; padding: 1em 0 1em 3em; }
</style>
<script src="js/Jquery1.7.js" type="text/javascript"></script>
<script src="js/jquery.ui.core.js" type="text/javascript"></script>
<script src="js/jquery.ui.widget.js" type="text/javascript"></script>
<script src="js/jquery.ui.mouse.js" type="text/javascript"></script>
<script src="js/jquery.ui.draggable.js" type="text/javascript"></script>
<script src="js/jquery.ui.droppable.js" type="text/javascript"></script>
<script src="js/jquery.ui.sortable.js" type="text/javascript"></script>
<script src="js/jquery.ui.accordion.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#catalog").accordion();
$("#catalog li").draggable({
appendTo: "body",
helper: "clone"
});
$("#cart ol").droppable({
activeClass: "ui-state-default",
hoverClass: "ui-state-hover",
accept: ":not(.ui-sortable-helper)",
drop: function (event, ui) {
$(this).find(".placeholder").remove();
$("<li></li>").text(ui.draggable.text()).appendTo(this);
}
}).sortable({
items: "li:not(.placeholder)",
sort: function ();
$(this).removeClass("ui-state-default");
}
});
});
</script>
</head>
<body>
<div class="demo">
<div id="products">
<h1 class="ui-widget-header">产品</h1>
<div id="catalog">
<h3><a href="#">家电用具</a></h3>
<div>
<ul>
<li>空调</li>
<li>冰箱</li>
<li>电脑</li>
</ul>
</div>
<h3><a href="#">衣服</a></h3>
<div>
<ul>
<li>鞋子</li>
<li>风衣</li>
<li>裤子</li>
</ul>
</div>
<h3><a href="#">学习用品</a></h3>
<div>
<ul>
<li>钢笔</li>
<li>橡皮</li>
<li>铅笔</li>
</ul>
</div>
</div>
</div>
<div id="cart">
<h1 class="ui-widget-header">购物车</h1>
<div class="ui-widget-content">
<ol>
<li class="placeholder">Add your items here</li>
</ol>
</div>
</div>
</div>
<div class="demo-description">
<p>快乐购物,,欢乐你我</p>
</div>
</body>
</html>
相关文章推荐
- ASP.NET jQuery 实例11 通过使用jQuery validation插件简单实现用户登录页面验证功能
- 基于jquery的lazy loader插件实现图片的延迟加载[简单使用]
- 五滴水:使用Ajax+jQuery来实现前端收到的数据在console上显示+简单的主页设计与bootstrap插件实现图片轮播
- 简单测试实现 博客园的头像上传功能 使用插件jquery jcrop+fineupload
- ASP.NET jQuery 随笔 使用allValidator插件简单实现客户端验证功能
- ASP.NET jQuery 实例12 通过使用jQuery validation插件简单实现用户注册页面验证功能
- ASP.NET jQuery 食谱12 (通过使用jQuery validation插件简单实现用户注册页面验证功能)
- ASP.NET jQuery 食谱11 (通过使用jQuery validation插件简单实现用户登录页面验证功能)
- 基于jquery的lazy loader插件实现图片的延迟加载[简单使用]
- ASP.NET jQuery 实例12 通过使用jQuery validation插件简单实现用户注册页面验证功能
- 【jQuery插件】使用cropper实现简单的头像裁剪并上传
- ASP.NET jQuery 实例11 通过使用jQuery validation插件简单实现用户登录页面验证功能
- JQuery实现简单时尚快捷的气泡提示插件
- thinkphp使用ajax、jquery、Mysql实现了简单的客户端通信功能
- 简单jQuery插件实现
- 使用jquery.form.js实现form表单无刷新提交简单示例
- 使用jquery的 treetable插件实现树状结构 demo
- 使用jQuery插件realshadow实现超酷真实阴影效果
- 一个简单的jQuery插件ajaxfileupload实现ajax上传文件例子
- 使用jquery 简单实现下拉菜单