2013-10-21 74 views
0

我想一個類定義添加到與button : { }我怎麼這樣做沒有做這樣的事情$('.ui-dialog-buttonpane button:eq(0)')jQuery的對話框添加自定義類按鈕

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"); 
       } 
       } 
      }); 
      }); 

回答

2

您可以使用此選項creatured元素對象來指定類名。

$("#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

相關問題