六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 30|回复: 0

jQuery ajax删除

[复制链接]

升级  44.67%

102

主题

102

主题

102

主题

举人

Rank: 3Rank: 3

积分
334
 楼主| 发表于 2013-1-23 01:18:24 | 显示全部楼层 |阅读模式
jQuery ajax删除


<!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>    <title>jQuery学习-ajax删除</title>    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />    <style type="text/css">        h1{color:Green;}        body{ background-color:#EEEEEE ; }        .list{                background:#EEEEEE none repeat scroll 0 0;                border-top:1px solid #CCCCCC;                padding:5px 10px;                width:300px;             }        .del{                color:Blue;                display:block;                float:right;                width:35px;            }    </style>    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>    <script type="text/javascript">        $(document).ready(function() {            $(".del").click(function() {                var $p = $(this).parent();                var $this = $(this);                $.ajax({                    type: "post",                    url: "http://hyipaying.com/demo/2010/10/delete.aspx",                    //得到id                    data: { id: $this.attr("id").replace('del-', '') },                    beforeSend: function() {                        //发送请求前改变背景色                        $p.css("backgroundColor", "#FB6C6C");                    },                    success: function() {                        //删除成功                        $p.slideUp(300, function() {                            //移除父级div                            $p.remove();                        });                    }                });//阻止浏览器默认事件return false;            });        });           </script></head><body>    <div>         <h1>jQuery ajax删除</h1>        <div class="list">            <a id="del-1" class="del" href="#">删除</a>            <strong>jQuery学习,jQuery框架学习</strong>        </div>            <div class="list">            <a id="del-2" class="del" href="#">删除</a>            <strong>jQuery学习,jQuery框架学习</strong>        </div>        <div class="list">            <a id="del-3" class="del" href="#">删除</a>            <strong>jQuery学习,jQuery框架学习</strong>        </div>        <div class="list">            <a id="del-4" class="del" href="#">删除</a>            <strong>jQuery学习,jQuery框架学习</strong>        </div>        <div class="list">            <a id="del-5" class="del" href="#">删除</a>            <strong>jQuery学习,jQuery框架学习</strong>        </div>        </div></body></html>"
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表