How to respond to an event for multiple elements?


#1

I need to respond to a user changing either the “From” date or the “To” (date with the same code). Assuming the “From” element has an Id of “day1shift1From” and the “To” element has an Id of “day1shift1To,” should the event definition be like this:

'change #day1shift1From #day1shift1To': function(event) {
	// respond to the change
}

(space-separated element IDs)

…or like this:

'change #day1shift1From, #day1shift1To': function(event) {
	// respond to the change
}

(comma-separated element IDs)

Or are both of the above wrong OR is it preferred to give both elements the same class name (such as “day1shift1”), and then define the handler like this:

'change .day1shift1': function(event) {
	// respond to the change
}

?


#2
'change #day1shift1From, change #day1shift1To': function (event) { 
  ...

That’s what you need.