मैं ले लिया है मार्क कोलमैन स्क्रिप्ट और मेरी जरूरतों के लिए इसे थोड़ा बढ़ाया।
मैं इसे आपके साथ साझा करना चाहते हैं:
$.fn.onAny = function(cb){
for(var k in this[0])
if(k.search('on') === 0)
this.on(k.slice(2), function(e){
// Probably there's a better way to call a callback function with right context, $.proxy() ?
cb.apply(this,[e]);
});
return this;
};
उपयोग::
$('#foo').onAny(function(e){
console.log(e.type);
});
इसके अलावा, आप बस का उपयोग कर सकते ब्राउज़र http://jsfiddle.net/msSy3/65/
var lastEvent = null,
countEvent = 0;
$("#test").bind("blur focus focusin focusout load resize scroll unload click" + " dblclick mousedown mouseup mousemove mouseover mouseout mouseenter " + "mouseleave change select submit keydown keypress keyup error", function (e) {
if (lastEvent !== e.type) {
countEvent++;
$("#r").prepend("<span>" + countEvent + ": " + e.type + "<br></span>");
$("#r > span:nth-child(21)").remove();
lastEvent = e.type;
}
});
क्रोम 12 और एफएफ 5 में टेक्स्टरेरा या इनपुट प्रकार बटन के लिए बिल्कुल कुछ भी नहीं है। – Bobby
@ बॉबी गायब '.llice (2)' - मैंने इसे ठीक किया था। –