별의 공부 블로그 🧑🏻‍💻
728x90
728x170
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<!-- 선택자 호환성 문제 해결 -->
<html>
<head>
    ....
</head>
<body>
<div id="wrap">
    <p>내용1</p>
    <p>내용2</p>
    <p>내용3</p>
    <p>내용4</p>
</div>
<script type="text/javascript">
    document.getElementById("wrap").children[0].style.color="red";
    
    var p=document.getElementsByTagName("p")[1];
    var nextObj=p.nextSibling;
    while(nextObj.nodeType != 1) {
        nextObj=nextObj.nextSibling;
    }
    nextObj.style.backgroundColor="yellow";
</script>
</body>
</html>
cs

 

 

소스 출처 : Do It! 자바스크립트+제이쿼리 입문 (정인용 지음, 이지스퍼블리싱)

728x90
그리드형(광고전용)
⚠️AdBlock이 감지되었습니다. 원할한 페이지 표시를 위해 AdBlock을 꺼주세요.⚠️
starrykss
starrykss
별의 공부 블로그 🧑🏻‍💻


📖 Contents 📖