日期:2014-05-16 浏览次数:20321 次
<!DOCTYPe html>
<html>
<head>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js'></script>
</head>
<body>
<div class='divclassa'>a</div>
<div class='divclassb'>b</div>
<div class='divclassc'>c</div>
<script type='text/javascript'>
var fn = function() {
alert('hi');
}
$.fn.jqueryName = function(eventname, fns) {
var _this = this;
this.each(function(i, dom) {
$(dom).bind(eventname, function() {
fns();
_this.filter(':not(dom)').bind(eventname, fns).trigger(eventname);
});
});
}
$('.divclassa,.divclassb,.divclassc').jqueryName('click', fn);
</script>
</body>
</html>