메뉴 건너뛰기

조회 수 276 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

javascript for문 사용 예

//예문1) 미지원 브라우저 없음
for (var i=0; i<array.length; i++) {
    console.log(array[i]);
}

//예문2.1) ie8 이하 미지원
for (var i in array) {
    console.log(array[i]);
}

//예문2.2) object형 변수의 루프 돌리기
var viewModel = {
    entity : undefined,
    longitude: 127.33887522,
    latitude: 36.34803794,
    height: 0,
    heading: 0,
    pitch: 0,
    roll: 0
};
for (var name in viewModel) {
    console.log(name + ": " + viewModel[name]);
}

//예문3.1) ie9, ff1.5 미만 미지원
array.forEach(function(currentValue, index, arr), thisValue);

//예문3.2) ie9, ff1.5 미만 미지원
var numbers = [65, 44, 12, 4];
function myFunction(item, index, arr) {}
numbers.forEach(myFunction);

 

jQuery 루프문 사용 예

//예문1)
$("li").each(function(index) {
    console.log(index + ": " + $(this).text());
});

//예문2)
$("div").each(function(index, element) {
    //$(element) == $(this)
    $(element).css("color", "yellow");
    if ($(this).is("#stop")) {
        $("span").text("index : " + index);

        //continue : return true;
        //break : return false;
        return false;
    }
});

//예문3)
var result = {
    navigationList : {
        "0": {
            "coordinatex" : "126",
            "coordinatey" : "36",
        },
        "1": {
            "coordinatex" : "126",
            "coordinatey" : "36",
        }
    }
};
$.each(result.navigationList, function(idx, data) {
    console.log('for:',data.coordinatex, data.coordinatey);
});

//예문4)
var obj = {
    "a": "1",
    "b": "2"
};
$.each(obj, function(key, value) {
    alert(key + ": " + value);
});

//예문5)
$.each([52, 97], function(index, value) {
    alert(index + ": " + value);
});

  1. jqGrid / custom pager / custom paging / 그리드 / 페이징

  2. No Image 25Mar
    by 조쉬
    2021/03/25 Views 276 

    javascript, jQuery에서 루프 돌리기 예 (for, forEach, each)

  3. No Image 21Sep
    by
    2016/09/21 Views 6801 

    Input TYPE=“File” 을 히든으로 하고 외부 버튼을 눌러서 파일을 선택

  4. No Image 26Mar
    by
    2021/03/26 Views 176 

    input checkbox 모두 체크하기

  5. No Image 07Nov
    by
    2018/11/07 Views 1403 

    iframe height auto resize

  6. No Image 18Nov
    by
    2016/11/18 Views 7118 

    html 테이블 고정 (table fixed)

  7. Html 색상표 모음, 색상코드표 (RGB), 이미지X, 복사 가능

  8. hover 메소드를 이용해서 메뉴 on, off를 구현

  9. No Image 07Nov
    by
    2018/11/07 Views 1296 

    Hide pager if bxslider has only 1 slide

  10. No Image 21Sep
    by
    2016/09/21 Views 8566 

    Get방식 파라미터 전송 & 탭 메뉴 선택

  11. No Image 21Sep
    by
    2016/09/21 Views 7125 

    getScript()

  12. No Image 21Sep
    by
    2016/09/21 Views 8379 

    getJSON() 함수

  13. No Image 07Nov
    by
    2018/11/07 Views 1299 

    getElementsByClassName 을 IE8 이하에서 동작하게 하는 코드

  14. No Image 21Sep
    by
    2016/09/21 Views 7346 

    FORM 객체 초기화 하기

  15. No Image 26Mar
    by
    2021/03/26 Views 195 

    foreach문

  16. No Image 26Mar
    by
    2021/03/26 Views 171 

    focus() 로 오브젝트 옮기기

  17. No Image 26Mar
    by
    2021/03/26 Views 285 

    fadeIn() , fadeOut() 을 이용한 간단한 자동 그림 전환

  18. easing - 효과의 진행 속도

  19. No Image 31Mar
    by
    2021/03/31 Views 273 

    draggable - div 드래그

  20. No Image 21Sep
    by
    2016/09/21 Views 6810 

    document.getElementById() 처럼 DOM 객체 얻기

Board Pagination Prev 1 ... 3 4 5 6 7 8 9 Next
/ 9

하단 정보를 입력할 수 있습니다

© k2s0o1d4e0s2i1g5n. All Rights Reserved