有人可以帮我添加一个类到ui-dialog-buttonset ..我有2个按钮“添加”和“删除”,并希望每个都适当地设置样式。
如何在“添加此项目”
按钮中添加一个类$dialogContent.dialog({
modal: true,
resizable: false,
title: "New thing",
close: function() {
$dialogContent.dialog("destroy");
$dialogContent.hide();
$('#other').stuff("removeUnsavedEvents");
},
buttons: {
'Add this item' : function() {
if(client_url.val() == '')
{
alert('client not selected');
$other.stuff("removeUnsavedEvents");
$dialogContent.dialog("close");
return;
}
$dialogContent.dialog("close");
},
});
update_stuff_overview();
}
}
}
由于
编辑从ui-dialog插件添加html ..
<div class="ui-dialog-buttonset">
<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">Add this item</span>
</button>
</div>
我正在尝试将“new_class”添加到上面的按钮。
答案 0 :(得分:0)
以下是答案
var button_text = $('#button-id').attr('value');
if(button_text == 'Add this item'){
$('#button-id').addClass('class_name');
}
答案 1 :(得分:0)
在对话框的打开事件中添加:
$(this).parent().find('button:nth-child(1)').addClass('your-class-name');
它只会设置第一个按钮的样式。如果要设置其他按钮的样式,请以相同的方式应用,但更改子编号(例如'button:nth-child(2)')。这就是我在jQuery 1.9中设置按钮的样式