-4

According to my autosave function (link here). Which is triggered by something change to the element. In this case blur and change - input text and checkbox.

I want to make the function working on both typing and clicking the box. Because there're both element type in the same line.

I tried $('xxx').on('blur change',function()...

But only change is working. Any idea???

Wilf
  • 2,297
  • 5
  • 38
  • 82

1 Answers1

1

You can use this type of pattern. And define a new function commonFunction that contains common code for both the events.

$("xxx").on({
    blur: function() {
        // Handle blur...
        commonFunction();
    },
    change: function() {
        // Handle change...
        commonFunction();
    }
});
Ankit Agarwal
  • 30,378
  • 5
  • 37
  • 62