,你可以做以下
$(document).ready(function() {
var testing = $('#testing');
testing.click(function() { });
testing.change(function() { });
testing.mouseover(function() { });
});
或(使用链):
$(document).ready(function() {
/* var testing = */ $('#testing') // the assignment is optional, but you can reuse the selector
.click(function() { })
.change(function() { })
.mouseover(function() { });
});
与bind
您可以创建如。自定义事件处理:
$(document).ready(function() {
var testing = $('#testing');
testing.bind('fill', function() { });
testing.trigger('fill');
});
通过的实况看书,你也可以这样做:
$(document).ready(function() {
/* var testing = */ $('#testing') // the assignment is optional, but you can reuse the selector
.bind('click change mouseover', function() { });
});
或使用jQuery 1.4:
$(document).ready(function() {
/* var testing = */ $('#testing') // the assignment is optional, but you can reuse the selector
.bind({
click: function() { },
change: function() { },
mouseover: function() { }
});
});
+1为自定义事件。 – Kobi 2010-08-03 05:40:47