简体   繁体   中英

jquery for loop is not working in dialog div button click

This is jQuery code while button click the for loop is not working in dialog div submit date button please some one help me friends. . .

$("#dialog-form").dialog({
    autoOpen: false,
    height: 300,
    width: 350,
    modal: true,
    buttons: {
        "Submit Date": function () {
            for (var j = 1; j <= MGDval; j++) {
                alert($('S' + j).val());
            }
            $(this).dialog("close");
        },
        Cancel: function () {
            $(this).dialog("close");
        }
    },
    close: function () {
        $(this).dialog("close");
    }
});
alert($('S'+j).val());

change to :

alert($('#S'+j).val()); // => for ID

alert($('.S'+j).val()); // => for Class

if selector element "S" : "#S" or ".S"

s does nor refer to any thing chnage to .s for class or #s for Id

alert($('#S'+j).val());

alert($('.S'+j).val());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM