我正在更新网站并逐渐将所有位更改为 jquerymobile 以使其对手机更加友好。
我有一个页面,用户可以在其中选择特定月份或日期范围。我使用一些javascript在它们之间切换。但是,由于更改内容,显示:块等似乎无法正常工作。它显示它们不在位置。当您在它们之间切换时,输入字段现在显示在选择器上方。请参阅http://jsfiddle.net/pfLme/1/
显然我想让他们进入正确的位置。(下一个任务是尝试让 Datepicker 工作 - 如果有人愿意为我指出正确的方向)
谢谢你。
(代码都在 jsfiddle 上,但是 stackoverflow 告诉我我也需要在这里包含它)
function showType(allornone) {
if (allornone == '1month')
{
document.getElementById('btwdateselector').style.display = 'none';
document.getElementById('monthselector').style.display = 'block';
document.getElementById('datestart').value = '';
document.getElementById('dateend').value = '';
}
if (allornone == '2dates')
{
document.getElementById('btwdateselector').style.display = 'block';
document.getElementById('monthselector').style.display = 'none';
}
} //end function
...我现在当然意识到我必须习惯于思考和利用 jquery mobile 的 jquery 方面。到目前为止,我想出了
$(document).on('click', '#certainmonth', function(a) {
$('#monthselector').hide();});
$(document).on('click', '#btwdates', function(a) {
$('#btwdateselector').show();});
我还不确定如何包含 if 语句并在显示和隐藏之间切换。