【问题标题】:Jquery Dialog add custom class to buttonJquery Dialog将自定义类添加到按钮
【发布时间】:2013-10-21 21:31:09
【问题描述】:

我希望将类定义添加到使用button : { } 创建的元素中,而无需执行$('.ui-dialog-buttonpane button:eq(0)') 之类的操作。

http://jsfiddle.net/3zcEY/

     $(function() {
            $( "#dialog-confirm" ).dialog({
              resizable: false,
              height:140,
              modal: true,
              buttons: {
 //add a class definition to the delete all items button here. tried  
//class:'save' didn't work

                "Delete all items": function() {
                  $( this ).dialog( "close" );
                },
                Cancel: function() {
                  $( this ).dialog( "close" );
                }
              }
            });
          });

【问题讨论】:

    标签: jquery html dialog


    【解决方案1】:

    您可以使用选项对象来指定类名。

    $("#dialog-confirm").dialog({
            resizable: false,
            height: 140,
            modal: true,
            buttons: {
                //add a class definition here.
                "Delete all items": {
                    'class': 'customClass', //<-- specify the class here
                    text: 'Delete all items', //<-- text for the button
                    click: function () { //click handler
                        $(this).dialog("close");
                    }
                },
                Cancel: function () {
                    $(this).dialog("close");
                }
            }
        });
    

    Fiddle

    【讨论】:

      猜你喜欢
      • 2015-06-23
      • 1970-01-01
      • 2018-09-14
      • 1970-01-01
      • 2014-07-29
      • 1970-01-01
      • 1970-01-01
      • 2013-09-07
      • 1970-01-01
      相关资源
      最近更新 更多