跨浏览器的datepicker组件(与移动和桌面浏览器兼容)和Bootstrap

nig*_*tch 6 mobile html5 cross-browser datepicker twitter-bootstrap

有没有可以在移动浏览器(Android,iOS,Windows手机)和标准浏览器中使用的datepicker库?如果它与Bootstrap css兼容,并且如果它可能在可能的情况下回退到原生的html5日期字域,那将是完美的.请推荐一下.我试过 - webshims(在Android和IE中破解) - pickadate(不满意它的行为方式)

Fri*_*esh 3

JQuery UI 是你的朋友...这是一个示例

<head>
<script type="text/javascript">
    var datefield=document.createElement("input")
    datefield.setAttribute("type", "date")
    if (datefield.type!="date"){ //if browser doesn't support input type="date", load files for jQuery UI Date Picker
        document.write('<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />\n')
        document.write('<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"><\/script>\n')
        document.write('<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"><\/script>\n') 
}
</script>

<script>
if (datefield.type!="date"){ //if browser doesn't support input type="date", initialize date picker widget:
    jQuery(function($){ //on document.ready
        $('#birthday').datepicker();
    })
}
</script>
</head>

<body>
    <form>
        <b>Date of birth:</b>
        <input type="date" id="birthday" name="birthday" size="20" />
        <input type="button" value="Submit" name="B1"></p>
    </form>
</body>
Run Code Online (Sandbox Code Playgroud)