函数调用时更改div的z-index? [英] Changing the z-index of a div when a function is called?

查看:109
本文介绍了函数调用时更改div的z-index?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调用createCustomerCard('CUST_0')时,它会打开第一张订单卡,位于

 < div id =CUST_0 class =widget ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggablestyle =width:500px; height:auto; font-size:11px; display:block; left:29px; top:156px; z-index:1013;> 

的z-index为1013,但如果您尝试调用相同的函数,卡或不增加z-index,因为如果创建了CUST_01卡,则z-index高于CUST_0的z-索引。是否有一种方法可以在函数被调用时将z-index增加1?

CUST_2下面的示例

 < div id =CUST_2class =widget ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggablestyle =width :500px; height:auto; font-size:11px; display:block; z-index:1014; left:319px; top:162px;> 


解决方案

添加到样式 position:相对表示@Mr Lister或位置:绝对

 < div id =CUST_0class =widget ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggablestyle =width:500px; height:auto; font-size :11px; display:block; left:29px; top:156px; position:relative; z-index:1013;> 

并添加jQuery其中是函数调用:

  $('#CUST_N')。css(z-index,$('#CUST_N')。css(z-index)+ 1); 


When createCustomerCard('CUST_0') is called it opens the first order card below

<div id="CUST_0" class="widget ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable" style="width: 500px; height: auto; font-size: 11px; display: block; left: 29px; top: 156px; z-index: 1013; ">

with z-index of 1013, but if you try call the same function its either not drawing the customer card or not increasing the z-index beacause if a CUST_01 card is created the z-index is above the z-index of CUST_0. is there a way to increase the z-index by 1 for a div id when the function is called?

CUST_2 example below

<div id="CUST_2" class="widget ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable" style="width: 500px; height: auto; font-size: 11px; display: block; z-index: 1014; left: 319px; top: 162px; ">

解决方案

Add to style position:relative says @Mr Lister or position:absolute:

<div id="CUST_0" class="widget ui-dialog ui-widget ui-widget-content ui-corner-all ui-draggable" style="width: 500px; height: auto; font-size: 11px; display: block; left: 29px; top: 156px; position:relative;z-index: 1013; ">

and add jQuery where is the function called:

$('#CUST_N').css("z-index", $('#CUST_N').css("z-index")+1);

这篇关于函数调用时更改div的z-index?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆