【问题标题】:Add calendar jquery image to datepicker将日历 jquery 图像添加到 datepicker
【发布时间】:2012-05-12 09:04:01
【问题描述】:

我不确定如何将 ui-icon ui-icon-calendar 类添加为文本字段旁边的日期选择器图像。我想要这样的东西:http://jqueryui.com/demos/datepicker/#icon-trigger,但它应该有 jquery 日历图像。

【问题讨论】:

标签: jquery jquery-ui datepicker jquery-ui-datepicker


【解决方案1】:
<script>
        $(function() {
            $( "#datepicker" ).datepicker({
                showOn: "button",
                buttonImage: "http://jqueryui.com/resources/demos/datepicker/images/calendar.gif",
                buttonImageOnly: true
            });
        });
</script> 

【讨论】:

    【解决方案2】:

    如果您单击链接到的示例下方的查看源代码按钮,您将看到如下内容:

    $('#field').datepicker({        
        buttonImage: '/images/calendar_icon.png'
    });
    

    【讨论】:

    • 我的下载文件中没有 calendar_icon.png。所以我想使用 ui-icon-calendar 图像。
    【解决方案3】:

    通过这个我们可以从字段中清除给定的日期,尽管该字段是只读的。它应该是只读的,不能由用户给出,必须从日期选择器中选择。

    html:

    $("#datepickerID").datepicker({          
        showOn: "button",
        buttonImage: "images/calendar.png",
        buttonImageOnly: true,
        buttonText: "Select date",
        minDate : 0,
        showButtonPanel: true,
        closeText: 'Clear',
        onClose: function () {
            var event = arguments.callee.caller.caller.arguments[0];
            // If "Clear" gets clicked, then really clear it
            if ($(event.delegateTarget).hasClass('ui-datepicker-close')) {
                $(this).val('');
            }
        }
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-06-05
      • 2012-11-24
      相关资源
      最近更新 更多