代码之家  ›  专栏  ›  技术社区  ›  Neil Outler

如何使jQueryUIDatePicker显示在输入字段的左侧?

  •  2
  • Neil Outler  · 技术社区  · 16 年前

    我想让datepicker显示在输入的左侧。我有办法做到这一点吗?到目前为止,我已经在测试页面中尝试了这段代码,但仍然无法从下面更改位置。

          $(".date").datepicker({
            changeYear: true,
            dateFormat: 'mm/dd/yy',
            constrainInput: true,
            yearRange: 'c-125:c+125',
            showAnim: "", 
            showOptions: { direction: "up" }
          });
    
    2 回复  |  直到 16 年前
        1
  •  1
  •   N V Harikrishna    12 年前

    您可以使用datepicker的isRTL属性,例如:

    $('#datepicker').datepicker({
        isRTL: true,
        ...
    });
    

    可以找到更多信息@ http://api.jqueryui.com/datepicker/#option-isRTL

        2
  •  0
  •   KyleMit Steven Vachon    13 年前

    例如:

    HTML代码:

    <div id="dtPicker">Date:
        <input type="text" id="datepicker"/>
    </div>
    

    div#dtPicker {
        direction: rtl;
    }
    

    JS:

    $("#datepicker").datepicker({
        showOn: "button",
        buttonImage: "../../icon.png",
        buttonImageOnly: true
    });
    

    图标应出现在输入字段的左侧。:)

    或者在自定义css中,您可以覆盖图像的jQuery ui css。

    .ui-datepicker-trigger {
        float: left;
    }