开发者

Implement jQuery addClass to a modal dialog button

开发者 https://www.devze.com 2023-02-24 06:51 出处:网络
$(document).ready(function() { $( \"#addLocation\" ).dialog({ modal: true, height: 820, width: 550, buttons: {
$(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()

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号