小编Iva*_*var的帖子

jquery datepicker - 覆盖data-attribute中的选项

我正在使用这个标记

<label> Date <input type="text" data-datepicker="{maxDate: '+1d'}" /></label>
<label> Another date <input type="text" data-datepicker="" /></label>
<script>
$('[data-datepicker]').each(function() {
      // init the options var with some default values (dateFormat etc)
      // that can be overridden by the data-datepicker values
      // also, new values can be added to the options from data-datepicker
      // such as in the above example "maxDate"
      var options = TODO;      

      $(this).datepicker(options);
});
</script>
Run Code Online (Sandbox Code Playgroud)

我真的不知道从哪个选项对象开始.从默认值开始似乎是一个好的开始

var options = { dateFormat: 'yy-mm-dd }; 
Run Code Online (Sandbox Code Playgroud)

但后来我如何添加/覆盖数据属性的值..我只是不知道

jquery jquery-ui custom-data-attribute jquery-ui-datepicker

9
推荐指数
1
解决办法
1万
查看次数