Implement jQuery addClass to a modal dialog button
$(document).ready(function() {
$( "#addLocation" ).dialog({
modal: true,
height: 820,
width: 550,
buttons: {
"Add Location": f开发者_如何学运维unction() {
document.forms['mapform'].submitted.value='1';
document.forms["mapform"].submit();
},
Cancel: function() {
$( this ).dialog( "close" );
}
},
});
});
How can I implement the addClass
function to the 'Add Location' button on the modal dialog?
Thanks,
Make buttons an array and set the button as an object
buttons: [{
text: "Add Location",
click: function() {
document.forms['mapform'].submitted.value='1';
document.forms["mapform"].submit();
},
class: "myCssClass"}]
does $(this).addClass("myCssClass")
not work?
And if not, let the browser rendering the button and add aftwardes the the css class.
$("#addLocation").dialog("widget").find(".ui-dialog-buttonset button:eq(0)").addClass("");
You just need to set the correct index for :eq()
精彩评论