【问题标题】:Extending a jQuery plug-in's options扩展 jQuery 插件的选项
【发布时间】:2011-08-14 03:56:44
【问题描述】:

假设我有一个名为 common.js 的 JavaScript 文件和另一个名为 specific.js 的文件。在common.js 我有以下内容:

$(".datePicker").datepicker({
  changeMonth: true,
  changeYear: true,
  selectOtherMonths: true
});

我想通过添加onSelect 选项将选项扩展到specific.js 中的DatePicker 插件。

如何做到这一点?通过添加以下内容?

$(".datePicker").datepicker({
  changeMonth: true,
  changeYear: true,
  selectOtherMonths: true
});

【问题讨论】:

    标签: javascript jquery jquery-ui jquery-plugins javascript-framework


    【解决方案1】:

    你可以使用这种语法(在 jQuery 插件中很常见):

    $( ".selector" ).datepicker( "option", "option-name", 'option-value' );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-03-24
      • 1970-01-01
      • 1970-01-01
      • 2010-11-12
      • 2010-12-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多