I want to add css class on buttons of a jquery dialog box.
Here is my code :
$(document).ready(function(){ $('#messageBox p').html('bla bla bla. Ok?'); $('#messageBox').dialog({ modal : true, buttons: { 'Yes': function() { doSomething(); $(this).dialog('close'); }, 'No': function() { doAnotherThing(); $(this).dialog('close'); } } }); });
For example, I would like add ".red" class on my "yes" button.
How can I do that?
Thank you!
buttons: [ { text: "Submit", "class": 'submit_class_name', click: function() { $(this).dialog("close"); } }, { text: "Cancel", click: function() { $(this).dialog("close"); } } ]
I've got the solution, thanks to Rich :
$(document).ready(function(){ $('#messageBox p').html('bla bla bla. Ok?'); $('#messageBox').dialog({ modal : true, dialogClass: 'dialogButtons', buttons: { 'Yes': function() { doSomething(); $(this).dialog('close'); }, 'No': function() { doAnotherThing(); $(this).dialog('close'); } } }); }); $("div.dialogButtons div button:nth-child(1)").addClass("oneCssClass"); $("div.dialogButtons div button:nth-child(2)").addClass("anotherCssClass");
Solved!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With