Cute Running Puppy
본문 바로가기
개발일기/웹 종합

JQuery

by 징구짱 2023. 1. 14.
728x90

2023.01.13

2-1 2주차 오늘 배울 것

  • 짝수 홀수 버튼 만들기
let count = 0
function hey(){
    count += 1
    if (count % 2 == 0){
        alert('짝수입니다!')
    }
    else {
        alert('홀수입니다!')
    }
}
<button onclick="hey()">영화 기록하기</button>

 

2-2 JQuery 시작하기

  • jQuery CDN

https://www.w3schools.com/jquery/jquery_get_started.asp

 

jQuery Get Started

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

2-3 JQuery 다뤄보기

  • 값 지정하기 .url()
<!--id를 지정-->
<input type="email" class="form-control" id="url" placeholder="name@example.com">

 

  • 값 가져오기 .val()

 

  • 숨기기 .hide()
<!--id 지정-->
<div class="mypost" id="post-box"...>

 

  • 보이기 .show()

 

  • 추가하기 .append()

let temp_html = ``

' (x) -> ` (백틱 ' ~ ' 자판에 있음)

 

  • 카드 추가하기
<!--카드 박스의 div에 id 지정-->
<div id='cards-box' class="row row-cols-1 row-cols-md-4 g-4">

 

2-4 JQuery 적용하기(포스팅 박스)

  • 영화 기록하기 버튼 클릭 시 박스가 열리고 닫기 누를 시 박스 닫힘
<script>
    function  open_box() {
        $('#post-box').show()
    }
    function  close_box() {
        $('#post-box').hide()
    }
</script>
<button onclick="open_box()">영화 기록하기</button>
<button onclick="close_box()" type="button" class="btn btn-outline-dark">닫기</button>

 

  • 박스 숨기기 (첫 화면에서)
display: none;

 

2-5 Quiz_JQuery 연습하기

 

  • 특정 문자열을 포함하는지 확인하는 메서드 .includes()
if (txt.includes('@') == true)

https://www.codingfactory.net/10899

 

JavaScript / Object / String.includes() / 특정 문자열을 포함하는지 확인하는 메서드

.includes() .includes()는 문자열이 특정 문자열을 포함하는지 확인하는 메서드이다. IE는 Edge부터 지원한다. 문법 string.includes( searchString, length ) searchString : 검색할 문자열로 필수 요소이다. 대소문자

www.codingfactory.net

 

2-6 서버-클라이언트 통신 이해하기

  • 서울시 OpenAPI

http://openapi.seoul.go.kr:8088/6d4d776b466c656533356a4b4b5872/json/RealtimeCityAir/1/99

  • JsonView

https://chrome.google.com/webstore/detail/jsonview/gmegofmjomhknnokphhckolhcffdaihd?hl=ko

 

JSONView

브라우저에서 JSON 문서를 보세요.

chrome.google.com

728x90

'개발일기 > 웹 종합' 카테고리의 다른 글

크롤링 연습 (기상청 홈페이지)  (0) 2023.01.18
파이썬 기초, 웹스크래핑(크롤링) 기초  (0) 2023.01.18
Ajax  (0) 2023.01.14
부트스트랩, Javascript 사용  (0) 2023.01.14
html, css 기본 내용  (0) 2023.01.14