jQuery | javascript | CSS

30.jQuery - RemoveAttr ( 03.Attributes - 04.RemoveAttr)

Godffs 2009. 11. 10. 10:14
반응형

04.RemoveAttr.htm

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>특정 속성을 지우기</title>

    <script src="../jQuery/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>

    <script type="text/javascript">

        $(document).ready(function() {

            //버튼 클릭시 특성/속성/attribute/어트리뷰트/애트리뷰트 제거

            $('#btnRemove').click(function() {

                $('img:first').removeAttr("src"); //src 속성 삭제

            });

        });

    </script>

</head>

 

<body>

    <!--버튼 클릭시 동적으로 이미지 경로 삭제-->

    <input type="button" id="btnRemove" value="src삭제" />

   

    <img src="../ProductImages/thumbs/HARDWARE-01.jpg" alt="하드웨어"/>

    <img src="../ProductImages/thumbs/HARDWARE-01.jpg" alt="하드웨어"/>

   

</body>

</html>


결과화면

[그림30-1]



반응형