【问题标题】:Facing issue with calendar image日历图像面临问题
【发布时间】:2020-11-04 04:16:28
【问题描述】:

当用户单击输入文本框旁边的图像时,我正在使用 Juery Datepicker。

我尝试使用下面的代码 sn-p 来显示按钮图像,但不确定图像没有加载。

<input id="timeFrom" type="text" class="form-control" name="timeFrom">
 timeFrom.datepicker({
                 showOn: 'button',
            buttonImage: "~/Content/images/calendar.gif",
            buttonImageOnly: true 
        });

我已将日历图像放置在同一路径中,但在 UI 中日历图像未显示

谁能告诉我如何显示calendar.j

【问题讨论】:

    标签: javascript jquery jquery-ui


    【解决方案1】:

    我觉得你的 buttonImage 的路径不好,检查一下。

    $('#timeFrom').datepicker({
        showOn: "both",
        buttonImage: "https://findicons.com/files/icons/99/office/128/calendar.png",
        buttonImageOnly: true
    });
    .ui-datepicker-trigger {
        max-width: 24px;
        max-height: 24px;
        position: relative;
        top: 6px;
        left: 6px;
    }
    <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css " />
    <script src="http://code.jquery.com/jquery-2.1.3.js"></script>
    <script src="http://code.jquery.com/ui/1.11.2/jquery-ui.js"></script>
    <input id="timeFrom" type="text" class="form-control" name="timeFrom">

    【讨论】:

    • 我不知道为什么只有当我将路径放在按钮图像中时才能加载。如果我在 cshtml 中拖动它,它的加载正确。图像存在于图像文件夹中。如果还有什么遗漏,请告诉我。即使我像往常一样设置图像属性来设置输出。
    • 如果你觉得有用请验证我的答案
    【解决方案2】:

    我可以看到 url 发生变化的图像并且我可以看到图像

     timeFrom.datepicker({
                     showOn: 'button',
                buttonImage: "../Content/images/calendar.gif",
                buttonImageOnly: true 
            });
    

    【讨论】:

      猜你喜欢
      • 2015-03-22
      • 1970-01-01
      • 2023-03-29
      • 2020-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-29
      相关资源
      最近更新 更多