constdaysOfWeek=['mon','tue','wed','thu','fri','sat'];// Get Item from Array
console.log(daysOfWeek);// Add one more day to the array
daysOfWeek.push('sun');console.log(daysOfWeek);
2. ์์ ์ฐพ๊ธฐ
1
2
3
4
5
6
7
8
9
10
consthellos=document.getElementsByClassName('hello');console.log(hellos);consttitle=document.querySelector('#hello h1');// ID
consttitle=document.querySelector('.hello h1');// class
console.log(title);consttitle=document.querySelector('div.hello:first-child h1');console.dir(title);title.style.color='blue';
consth1=document.querySelector('div.hello:first-child h1');functionhandleTitleClick(){// console.log('title was clicked!');
h1.style.color='blue';}functionhandleMouseEnter(){// console.log('mouse is here!');
h1.innerText='Mouse is here!';}functionhandleMouseLeave(){// console.log('mouse is leaving');
h1.innerText='Mouse is gone!';}functionhandleWindowResize(){document.body.style.backgroundColor='tomato';}functionhandleWindowCopy(){alert('copier!');}functionhandleWindowOffline(){alert('SOS no WIFI');}functionhandleWindowOnline(){alert('ALL GOOD');}h1.addEventListener('click',handleTitleClick);h1.addEventListener('mouseenter',handleMouseEnter);h1.addEventListener('mouseleave',handleMouseLeave);// title.onclick = handleTitleClick;
// title.onmouseenter = handleMouseEnter;
window.addEventListener('resize',handleWindowResize);window.addEventListener('copy',handleWindowCopy);window.addEventListener('offline',handleWindowOffline);window.addEventListener('Online',handleWindowOnline);
<body><divid='login-form'><inputtype='text'placeholder='What is your name?'/><button>Log In</button></div><scriptsrc="app.js"></script></body>
4-1. Form Submission
1
2
3
4
5
6
7
8
<body><formid='login-form'><inputrequiredmaxlength="15"type='text'placeholder='What is your name?'/><!-- <button>Log In</button> --><inputtype='submit'value='Log In'/></form><scriptsrc="app.js"></script></body>
input์ ์ ํฝ์ฑ์ ๊ฒ์ฌํ๊ธฐ ์ํด์๋ input์ด form ์์ ์์ด์ผ ํ๋ค.