js弹出窗的用法
程序员文章站
2024-03-21 12:10:16
...
这几天在做排班系统,做好后的系统界面如下:
用户需求如下:
需要在轮休表中进行班次调整,请假,等.故利用js弹窗实现如下效果.
实现代码如下:
$('#user_table tbody tr').each(function () {
var name = $(this).children('td:eq(5)').html();
$(this).children('td:eq(2)').attr('onclick', 'paiban_click(this)');
for (var i = 6; i < $(this).children('td').length; i++) {
$(this).children('td').eq(i).attr('onclick', 'paiban2_click(this)');
}
})
function paiban_click(e) {
var this_id = $(e).attr('id');
var name = $(e).parent('tr').children('td:eq(5)').html();
$('#name').html(name)
var _seft = e;
var A_top = $(_seft).offset().top + 3 * $(_seft).outerHeight(true) / 4; // 1
var A_left = $(_seft).offset().left + 3 * $(_seft).outerWidth(true) / 4;
$('#selectType').show().css({ "position": "absolute", "top": A_top + "px", "left": A_left + "px" });
$(document).click(function (event) {
if (event.target.id != this_id) {
$('#selectType').hide();
} else {
$('#selectType').show();
}
});
}
上一篇: android的自定义弹出窗