Element 객체

이동건 (불꽃냥펀치)·2025년 2월 23일
0
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../jquery.js"></script>
</head>
<body>
    <a id="target" href="http://opentutorials.org">opentutorials</a>
    <a id="t1" href="http://opentutorials.org">opentutorials</a>
    <input type="checkbox" id="t2" checked="checked">
    <ul>
        <li class="marked">html</li>
        <li>class</li>
        <li id="active">java
            <ul>
                <li>core</li>
                <li class="marked">DOM</li>
                <li class="marked">BOM</li>
            </ul>
        </li>
    </ul>
    <script>
        var t = $('#target');
        console.log(t.attr('href'));
        t.attr('title','opentutorials')
        t.removeAttr('title');

        var t1= $('#t1');
        console.log(t1.attr('href'));
        console.log(t1.prop('href'));
        var t2=$('#t2');
        console.log(t2.attr('checked'));
        console.log(t2.prop('checked'));
        t2.removeAttr('checked');

        // 제이쿼리에서 특정 하위 부분의 엘리먼트만 찾고자할떄는?
        $('.marked','#active').css('background-color','red');
        // $('#active','.marked').css('background-color','blue');
        // 이렇게하면 작동되지 x 오른쪽에 있는 게 상위 클래스인거 같다
        $("#active .marked").css('background-color','green');
        // 띄워 쓰기를 해야지 작동한다
        $('#active').find('.marked').css('background-color','blue')
    </script>
</body>
</html>
profile
자바를 사랑합니다

0개의 댓글

관련 채용 정보