Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How could call on two elements at same time on Change event,
Doing like this dont work

C#
$("#timepickerTo").timepicker
        $("#timepicker").timepicker
            ({
            timeFormat: 'HH:mm',
            minTime: '08:00',
            maxTime: '17:00',
            step: "30",
            change: function () {
                var start = new Date("2014-12-12" + $("#timepicker").val()+":00Z");
                start = start.getTime();
                var end = new Date("2014-12-12T" + $("#timepickerTo").val()+":00Z");
                end = end.getTime();
                if (end >= start) {
                    alert("OK");


                }
            }
            });
Posted

You could use a jquery selector that gets both of the controls, such as:

JavaScript
$("[id^='timepicker']"  // all controls whose id starts with timepicker


http://api.jquery.com/category/selectors/[^]

However, I would not suggest it simply because it will not be clear what is happening. Just move all your function code into an explicit function and then wire both controls up separately calling that function.
 
Share this answer
 
Comments
Thanks7872 15-Dec-14 9:31am    
Yes. And another option would be to apply class and create a method for that class.
ZurdoDev 15-Dec-14 9:45am    
Css class and not JavaScript class, to be clear. Yes, that would also work.
Use class. See here : http://stackoverflow.com/a/22112426/2645738[^]

Regards..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900