<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>W3Cschool在线教程(w3cschool.cn)</title>
<script src="/statics/js/jquery-1.8.3.min.js"></script>
</head>
<body>
<div class='menu'>
点击这里
<div class='submenu'>自动移除</div>
</div>
<script>
(function() {
var myjQuery = jQuery.sub();
myjQuery.fn.remove = function() {
this.trigger("remove");
return jQuery.fn.remove.apply(this, arguments);
};
myjQuery(function($) {
$(".menu").click(function() {
myjQuery(this).find(".submenu").remove();
});
$(document).bind("remove",function(e) {
$(e.target).parent().hide();
});
});
})();
</script>
</body>
</html>