,你可以做以下
$(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