본문 바로가기
공부/Frontend

WEB_JavaScript(1) 3주차

by 유스베리이 2023. 4. 1.

#javascript를 넣는 방법 

html 안에서 <script> tag를 넣음

 

<script>
	document.write('hello world');
    
   </script>

자바 스크립트는 동적임. 

html 는 정적임.

 

#이벤트

<input type ="button" value = "hi" onclick="alert('hi')"> //onclick 속성 값은 js

-웹브라우저 일어나는 것을 이벤트라고 함

<input type="text" onchange = "alert('changed')">
<input type="text" onkeydown = "alert('key down!')">

#콘솔

자바 스크립트 파일을 만들지 않아도 자바스크립트를 만들 수 있음

#데이터 타입

> six data types that are primitives

- boolean

-null

-undefined

-number (숫자)

-string (문자열)

<body style ="background-color : black ; color: white;">
</body>

-symbol 

> and object

 

 

 

str.length ( 문자열의 길이)

str.toUpperCase() ; ( 소문자를 대문자로)

str. indexOf() ; 문자의 인덱스 위치 알려줌

str.trim() ; 공백을 없애줌

 

#변수와 대입 연산자

> x =1;

< 1

> y =1 ;

< 1

> x + y;

< 2

 

#제어할 태그 선택

<body>

<input type = "button" value = "night" onclick="

	document.querySelector('body').style.backgroundColor = 'black';

	document.querySelector('body').style.color = 'white';
">
<input type = "button" value = "day" >
</body>

#비교 연산자와 블리언

<h3>1===1 </h3>

<script>
  document.write(1===1); //1과 1이 같은지 비교 연산자
 </script>
 

<h3>1&lt;2 </h3> //less than

<script>
  document.write(1<2); 
 </script>

1===1

1<2

//less than

#조건문

<body>
<h1> conditional statements </h1>
<script>
	document.write("1<br>");
    if(){
    document.write("2<br>");
    }
    else{
    document.write("3<br>");
    }
    document.write("4<br>");
    
    </script>

conditional statements

00

'공부 > Frontend' 카테고리의 다른 글

WEB-JavaScript (2) - 4주차  (0) 2023.04.08
GIT_ 3주차  (0) 2023.04.01
GIT / GIT HUB 공부 - 2주차  (0) 2023.03.25
웹개발_css 2주차 공부  (0) 2023.03.22
생활코딩_GIT/GIT hub 1주차 공부  (0) 2023.03.17