大佬教程收集整理的这篇文章主要介绍了jQuery – z-index操作和自动值而不是数字,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
jsfiddle示例 – http://jsfiddle.net/ynternet/84nVQ/10/
HTML
<div id="add" style="BACkground:yellow; width:100px;"> add new </div> <div id="container"> </div>
jQuery的
function handler() { if ($(this).find("#menu").length) { return; } var currenTindex = $(this).css('z-index'); alert(currenTindeX); var newIndex = currenTindex + 1; alert(newIndeX); $(this).css('z-index',newIndeX); } $("#add").on({ click: function(E) { var timestamp = Date.Now(); var posx = Math.floor(Math.random() * 400); var posy = Math.floor(Math.random() * 400); $('#container').append(function() { return $('<div class="add_to_this" id="' + timestamp + '" style="left:' + posx + 'px; top:' + posy + 'px; ">Click me,drag a change z-index</div>').click(handler).draggable({ containment: "#container",scroll: false,cursor: 'lock' }); }); } });
CSS
#container { width:500px; height:500px; BACkground: palegoldenrod; position: relative; top:20px; left: 100px; padding: 0px; } .add_to_this { padding:5px; BACkground:yellowgreen; position: absolute; display:inline-block; width:200px; height:50px; -moz-user-SELEct: none; -khtml-user-SELEct: none; -webkit-user-SELEct: none; user-SELEct: none; -o-user-SELEct: none; }
以上是大佬教程为你收集整理的jQuery – z-index操作和自动值而不是数字全部内容,希望文章能够帮你解决jQuery – z-index操作和自动值而不是数字所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。