검색결과 리스트
글
!markdown
# JavaScript (자바스크립트)
### 1. 가장 높은 수치의 z-index 구하기 Function
```js
function findHighestZIndex(tagName){
var highestIndex = 0;
//Makes parameter array
if (!tagName){
tagName = ['div'];
}else if (typeof tagName == 'string'){
tagName = [tagName];
}
//Search
if (tagName instanceof Array){
for (var i=0; i<tagName.length; i++){
var elementList = document.getElementsByTagName(tagName[0]);
for (var i=0; i<elementList.length; i++){
var zIndex = document.defaultView.getComputedStyle(elementList[i], null).getPropertyValue("z-index");
if (zIndex > highestIndex && zIndex != 'auto'){
highestIndex = zIndex;
}
}
}
}else{
console.log('Could not get highest z-index. because, not good parameter', tagName);
}
return parseInt(highestIndex);
}
```
### 2. Function 호출
```js
var hightestIndex = findHighestZIndex('div');
```
OR
```js
var hightestIndex = findHighestZIndex(['div', 'span', 'p']);
```
### 참고
How can you figure out the highest z-index in your document? : [http://stackoverflow.com/questions/1118198/how-can-you-figure-out-the-highest-z-index-in-your-document](http://stackoverflow.com/questions/1118198/how-can-you-figure-out-the-highest-z-index-in-your-document)
'LANGUAGE > HTML & CSS & JS' 카테고리의 다른 글
[CryptoJS] SEED (0) | 2017.11.29 |
---|---|
[JavaScript] Context Path (0) | 2017.01.03 |
[JavaScript] 정리중... (0) | 2016.08.23 |
[Internet Explorer Test] IE 테스트하기 (2) | 2016.08.21 |
[JavaScript] control other iframe (iframe 제어하기) (0) | 2016.08.18 |