[JavaScript]

kate·2022년 2월 25일
0

javascript

목록 보기
3/4
  1. 간결한 문법
  2. 편리한 API
  3. 크로스

1. JQuery 기초.

$(선택자).행위;

<body>
    <h1>jQuery 기초</h1>
    <textarea id="content">jQuery를 배워보자</textarea>
    
    #code.jquery.com 접속 후 갖다 쓰기.
    <script
    src="https://code.jquery.com/jquery-3.5.1.js"
    integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
    crossorigin="anonymous"></script>
    
    #$(선택자).val(); JQuery 형식 활용하기
    <script>
        console.log($('#content').val());
    </script>
</body>

2. JQuery 이벤트

<body>
	<h1>jQuery 이벤트</h1>
    <button id="click">클릭</button>
    <script
  src="https://code.jquery.com/jquery-3.5.1.min.js"
  integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
  crossorigin="anonymous"></script>
    <script>
    	# 클릭 시 console 화면에 hello 출력
        function hello() {
            console.log('hello');
        }
        $('#click').click(hello);
    </script>
</body>

+ 익명함수

<script>
	# 클릭 시 console 화면에 hello 출력
    $('#click').click(function(){console.log('hello');});
</script>
    ```

0개의 댓글