开发者

Can z-index be used in javaScript and what is the use of jQuery?

开发者 https://www.devze.com 2023-02-06 14:30 出处:网络
I am doing a project wherein I want to use z-index and jQuery ,but I don\'t know how to use them. I am drawing 3D objects on the canvas and I want to select them,non overlapping objects gets selected

I am doing a project wherein I want to use z-index and jQuery ,but I don't know how to use them. I am drawing 3D objects on the canvas and I want to select them,non overlapping objects gets selected but both the overlapped objects get's selected when clicked, so I want to use z-index feature in javaS开发者_开发百科cript as I am coding in javaScript.Is jQuery required? as I am also using events.


yes, you can use javascript to get or set z-index as

yourElement.style.zIndex = 100;
zIndex = yourElement.style.zIndex;

jQuery is not required. But if you are already using it in same page then preferably use it.

$("#element").css('z-index',100);
zIndex = $("#element").css('z-index');


z-index is from CSS. Javascript is not required unless you are dynamically changing the z-index on some event on the page, such as a page click, then you do not need Javascript.

You do not necessarily need jQuery because jQuery IS Javascript and anything you can do in jQuery you can do in Javascript. But if you would like to save lots of time, use jQuery and either do .css('z-index', 2000) or .addClass('foo') where .foo is defined in css and has a z-index.

0

精彩评论

暂无评论...
验证码 换一张
取 消