본문 바로가기
웹개발/HTML

[JavaScript] 제이쿼리 23.04.14

by 6^6 2023. 4. 14.
728x90
<script>
    window.onload = function(){
        const button = document.getElementById('button');
        button.onclick = function(){
            return false;  //이러면 기능 사용 X.
        }
    }
</script>

<body>
    <a id="button" href="http://www.keduit.com">버튼</a>
</body>

 

 

 

 

<style>
    #box{
        width : 100px; height : 100px;
        background-color : aqua;
    }
    #box.hover{
        background-color: beige;
        border-radius: 50px;
    }
</style>
<script>
    $(document).ready(function () {
        $('h1').css('color', 'red');
        $('h1').css('background', 'black');

        $('img').attr('src', 'http://placehold.it/100x100');
        $('img').attr('width', '100');

        $('#box').hover(function () {
            $('#box').addClass('hover');
        }), function () {
            $('#box').removeClass('hover');
        }
    })
</script>

<body>
    <h1>Header</h1>
    <h1>Header</h1>
    <h1>Header</h1>
    <img>
    <div id="box"></div>
</body>

 

 

 

728x90

댓글