【问题标题】:Cross-browser datepicker component (compatible with mobile and desktop browsers) and with Bootstrap跨浏览器日期选择器组件(兼容移动和桌面浏览器)和 Bootstrap
【发布时间】:2015-09-15 22:20:10
【问题描述】:

是否有任何可以在移动浏览器(Android、iOS、Windows 手机)和标准浏览器中使用的日期选择器库?如果它与 Bootstrap css 兼容,并且在可能的情况下可以回退到原生 html5 日期字段,那将是完美的。请推荐一些东西。 我试过了 - webshims(在 Android 和 IE 中损坏) -pickadate(对它的行为不满意)

【问题讨论】:

    标签: html twitter-bootstrap mobile datepicker cross-browser


    【解决方案1】:

    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>
    

    【讨论】:

      猜你喜欢
      • 2011-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多