Home  >  Article  >  Web Front-end  >  Usage example of jquery pop-up box (2)_jquery

Usage example of jquery pop-up box (2)_jquery

WBOY
WBOYOriginal
2016-05-16 17:24:221083browse

The second situation is about the pop-up box. There is no close button, but when you click elsewhere, the pop-up box disappears. This also involves some issues about hierarchy. You must use js to add a higher level to the parent element of the pop-up box to avoid Covered by what follows.

Copy code The code is as follows:



询盘分配




  • 询盘详情

  • 联系人

  • 所在地

  • 来源









js code:
Copy code The code is as follows:

// JavaScript Document
$(function(){
var $window = $(window),
$doc = $(document),
$body = $('body');
//About the js code added and deleted by the administrator
var tabLi=$(".tabPanel").find("li");
tabLi.hover(function(){
$(this).addClass("hover").siblings(). removeClass("hover");
},function(){})
$(window).scroll(function() {
var pwdTips =$(".pwdTips");
var height=pwdTips.height();
var width=pwdTips.width();
var bodyHieght=$(window).height();
var bodyWidth=$(window).width();
if(!pwdTips.is(":hidden")){
pwdTips.css({
position: "fixed",
top: (bodyHieght-height)/2,
left:(bodyWidth-width)/2
});
}
});

var bgShadow = function(zindex) {
zindex = zindex?zindex:999;
var _bg = $('div.pwdTipsBg'),
bg_html = '
';
if(_bg.length === 0 ) {
_bg = $(bg_html);
}
$body.append(_bg);
_bg.css({
position : 'absolute',
top : ' 0px',
left : '0px',
width : $window.scrollLeft() $window.width() 'px',
height : $doc.height(),
'z -index' : zindex
});
return _bg;
};

var bindClick = function(obj,handlerEvent){
obj.bind("click",function (e){
e.preventDefault();
bgShadow(1001);
var select=$(this).attr('contentid');
var onLineId=$(this). attr('id');
var pwdTips=$(select);
if(handlerEvent!=null)
{
handlerEvent($(this));
}
pwdTips.show();
pwdTips.find(".closeBtn,.diaSmtRst").click(function(){
pwdTips.hide();
var _bg = $('div.pwdTipsBg' );
_bg.remove();
});
pwdTips.find('#onLineId').val(onLineId);

});
};
var show=tabLi.find("dt"),
addPanelBtn=$(".addPanelBtn"),
clickBtn=$(".clickBtn"); //Button assigned to person
var setValue= function(obj){
if($(obj).is('.addPanelBtn'))
{
$('#opename').attr('value',"") ;
$('#pwdRest').find('#userName').show();
}
else
{
$('#pwdRest').find(' #userName').hide();
$('#opename').attr('value',obj.text());
$("input.shareId").attr('value' ,obj.attr('id')) //Get the id value assigned to the person's pop-up box
}
}
$(function(){
bindClick(show,setValue);
bindClick(addPanelBtn,setValue);
bindClick(clickBtn,setValue);
});
/*Details pop-up box starts*/
var listInfo=$(".listName a" );
listInfo.click(function(e){
e.preventDefault();
var winDiaBox=$(this).closest("li").find(".winDiaBox");
$(".winDiaBox").hide().closest('li').removeAttr('style');
if(winDiaBox.is(':visible')) {
winDiaBox.hide ();
} else {
winDiaBox.show().parent("li").siblings("li").removeAttr('style')
.find(".winDiaBox"). hide();
$(this).closest("li").css("z-index",4);
}
return false;
})
$( ".winDiaBox").click(function(){return false;})
$(document).click(function(){
$(".winDiaBox").hide();
$ (".winDiaBox").parent().removeAttr("style");
})
/*End of details popup box*/
})

Details popup The box is displayed along with the loop, which reduces the need to use js to position the pop-up box based on the position of each loop list.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn