插件截图:
用途:点击链接或按钮时要确认是否继续当前操作。
插件代码:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
(
function
($){
$.fn.confirmer = function (options){
var defaults = {
msg: " Are you sure to delete it ? "
}
var options = $.extend(defaults, options);
var control = $( this );
$(control).click( function (){ return confirm(options.msg);});
};
})(jQuery);
$.fn.confirmer = function (options){
var defaults = {
msg: " Are you sure to delete it ? "
}
var options = $.extend(defaults, options);
var control = $( this );
$(control).click( function (){ return confirm(options.msg);});
};
})(jQuery);
用法:
1.$(".delete").confirmer();
2.$(".delete").confirmer({msg:'确认删除吗?'});
示例:
![ContractedBlock.gif](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
<!
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.confirmer.js < / title>
< html xmlns = " http://www.w3.org/1999/xhtml " >
< head >
< title > jquery.confirmer.js < / title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
< script type = " text/javascript " language = " javascript " src = " js/jquery.js " >< / script>
< script type = " text/javascript " language = " javascript " src = " js/jquery.confirmer.js " >< / script>
< script type = " text/javascript " >
$().ready( function (){
$( " .delete " ).confirmer();
// $(".delete").confirmer({msg:'确认删除吗?'});
})
< / script>
< / head>
< body >
< button id = " btnDelete " class = " delete " > 删除 < / button>
< a id = " lnkDelete " class = " delete " href = " http://www.g.cn " > 删除 < / a>
< / body>
< / html>
< script type = " text/javascript " language = " javascript " src = " js/jquery.js " >< / script>
< script type = " text/javascript " language = " javascript " src = " js/jquery.confirmer.js " >< / script>
< script type = " text/javascript " >
$().ready( function (){
$( " .delete " ).confirmer();
// $(".delete").confirmer({msg:'确认删除吗?'});
})
< / script>
< / head>
< body >
< button id = " btnDelete " class = " delete " > 删除 < / button>
< a id = " lnkDelete " class = " delete " href = " http://www.g.cn " > 删除 < / a>
< / body>
< / html>