1. jquery에 대하여 설명(장점)하시오.

javascript에 비해 html 객체 하나하나 다루기가 간편하고 쉽다.


2. jquery 의 아래의 함수를 설명하시오.

  • html()

html 메소드는 html 태그 형태로 가져온다.
안에 값을 넣을 경우 html로 쓴다

  • text()

text 메소드는 html 태그를 다 벗긴 채 text만 가져온다.

  • val()

input 안에 있는 value값 등을 가져오거나 조작할 때 쓴다.


3. jquery를 통하여, 태그 객체를 생성하는 방법은?

$("<p>안녕하세요</p>");

이런식으로 작성한다.


4. remove() 와 empty() 의 차이는?

remove()는 해당 노드(태그)를 지워버리는 것이고, empty()는 해당 노드(태그)의 내부를 지운다.


5. jquery를 이용하여 디지털 시계를 만드시오.

  • 코드

    <!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="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
      <script>
         $(document).ready(()=>{
          setTimeout(function timer(){
            const date = new Date();
                    const str = `${("00"+date.getHours()).slice(-2)}:${("00"+date.getMinutes()).slice(-2)}:${("00"+ date.getSeconds()).slice(-2)}`;
            $("body > div").html(str);
            setTimeout(timer, 1000);
          },1000 );
        });
      </script>
    </head>
    <body>
      <div></div>
    </body>
    </html>
  • 실행 결과


1개의 댓글

comment-user-thumbnail
2023년 7월 20일

좋은 글 감사합니다!

답글 달기
Powered by GraphCDN, the GraphQL CDN