我需要在grails datepicker中使用onchange事件,但是简单地在日期选择器中使用onchange事件不起作用。

这是代码:

<td>g:datePicker name="A"precision="month"years="${(startDate.getAt(Calendar.YEAR))..
(EndDate?.getAt(Calendar.YEAR))}"  value="${FIRst}"</td>

我需要为上述代码添加onchange事件。我该怎么办?

最佳答案

我建议您使用jquery做到这一点。因为g:datepicker将分解为不同的部分,所以在您的情况下2选择(月和年)。即:

$(document).ready(function() {
$('#A_month').live('change', function() {
 ...your code here....
});

$('#A_year').live('change', function() {
 ...your code here....
});
});

关于jquery - Grails Datepicker Onchange事件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14640886/

10-12 23:55