问题
I'm using the jquery mobile datebox from here: http://dev.jtsage.com/jQM-DateBox/ and I am setting the calTodayButton to true. The problem I have is when I click the button it just selects today's date which is fine but I also want it to close on click. Any ideas as to the best way to do this?
回答1:
Try adding an click event to the button which closes the parent container like this
$('.ui-datebox-controls').find('a.ui-btn').on("click",function(){
$(this).parent().parent('.ui-datebox-container').hide();
});
回答2:
The accepted solution didn't work for me, but this one did:
$('.ui-datebox-controls').find('a.ui-btn').live( 'click', function(){
$(this).parent().parent().parent().parent('.ui-datebox-container').hide();
});
来源:https://stackoverflow.com/questions/9815613/jquery-mobile-datebox-today-button-close-on-click