-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,235
  • 5
  • 33
  • 77

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
  • 29,658
  • 5
  • 35
  • 59