JavaScript_在layer弹出层按钮事件中获取iframe内元素的研究

官方文档对此未见提及,供大家参考。

layer.open({
    type: 2,
    skin: 'layui-layer-molv',
    title: "LS_MAN SHARE",
    area: ['100%', '100%'],
    shadeClose: false,
    content: "web/ls_man-share.html",
    btn: ['ok', 'cancel'],
    btn1: function (index, layero) {
        var grid = $(layero).find("iframe").contents().find("#jqGrid");//本文重点

        var rowKey = grid.getGridParam("selrow");
        if (!rowKey) {
            alert("Please select data!");
            return;
        }

        var selrowid = grid.getGridParam("selarrrow");
        for (var i = 0; i < selrowid.length; i++) {
            var row = grid.getRowData(selrowid[i]);
            //...do something else...
        }

        //...do something else...             
        layer.close(index);
    }
});

你可能感兴趣的:(JavaScript入门点滴,推荐)