2010-03-09 36 views
1

我有一個對話框,使用下面生成的代碼javascript和HTML創建。我想爲按鈕和容器添加「style = font-size:0.9em;」刪除「ui-button-text-only」類。jQuery-UI:刪除類對話框

你能幫我嗎?

感謝,

HTML:

<div class="ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"> 
    <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"> 
     <span class="ui-button-text">Save</span> 
    </button> 
    <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"> 
     <span class="ui-button-text">Cancel</span> 
    </button> 
    <button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"> 
     <span class="ui-button-text">Delete</span> 
    </button> 
</div> 

的Javascript:

<div id="dialogProduct" title="MyTitle"></div> 
<script type="text/javascript"> 
function CreateDialogProduct() { 
    $("#dialogProduct").dialog({ 
     bgiframe: true, autoOpen: false, minHeight: 350, maxHeight: 450, height: 350, 
     minWidth: 450, maxWidth: 550, width: 450, 
     modal: true, 
     buttons: { 
      Save: function() { 
       $.ajax({ 
        type: "POST", 
        url: "/Product/SaveOrUpdate", 
        data: {...}, 
        success: function(data) {...}, 
        error: function(XMLHttpRequest, textStatus, errorThrown) { 
        } 
       }) 
      }, 
      Cancel: function() {...}, 
      Delete: function() { 
       $.ajax({ 
        type: "POST", 
        url: "/Product/Delete", 
        data: {...}, 
        success: function(data) {}, 
        error: function(XMLHttpRequest, textStatus, errorThrown) { 
        } 
       }) 
      } 
     }, 
     beforeclose: function(event, ui) { 
     } 
    }); 
}  
jQuery(document).ready(function() { 
    CreateDialogProduct(); 
}); 
</script> 

回答

4
$('button').removeClass("ui-button-text-only"); 
$('button:parent').css('font-size', '0.9em'); 

//or if you want to do it in a single line: 
$('button').removeClass("ui-button-text-only").parent().css('font-size', '0.9em'); 

回覆評論: 如果你有一個CSS類,如:

.small{ 
    font-size:0.9em; 
} 

在包括CSS文件,你可以執行以下操作來代替:

$('button').removeClass("ui-button-text-only").parent().addClass('small'); 
+0

謝謝:)沒有可能將 「FONT-SIZE:0.9em」 在一個類中的.css文件? – 2010-03-09 07:34:59

+0

@Kris是的,請參閱更新。 – Amarghosh 2010-03-09 07:56:18