jQuery

[jQuery] jQuesy 이벤트

사악미소 2015. 12. 20. 19:26
반응형

[jQuery] jQuesy 이벤트


 event-1.html

<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>jQuesy 이벤트</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function() {

        // jQuery("선택자").이벤트명(익명함수) => 단축형
        jQuery("#btn").click(function() {
       
            jQuery("#display").text("환영합니다.");
        });
    });
</script>
</head>
<body>
    <h1>jQuesy 이벤트</h1>
    <hr/>
    <p><button type="button" id="btn">버튼을 눌러주세요.</button></p>
    <div id="display"></div>
</body>
</html>

  출력결과

 ② 출력결과



 event-2.html

<!doctype html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<title>jQuesy 이벤트</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript">
    jQuery(document).ready(function() {

        // jQuery("선택자").on("이벤트명", 익명함수); => 일반형
        jQuery("#btn").on("click", function() {

            jQuery("#display").text("환영합니다.");
        });
    });
</script>
</head>
<body>
    <h1>jQuesy 이벤트</h1>
    <hr/>
    <p><button type="button" id="btn">버튼을 눌러주세요.</button></p>
    <div id="display"></div>
</body>
</html>

  출력결과

 ② 출력결과


반응형