Element(변수).innerHTML : 열리고 닫히는 태그의, content 영역의 텍스트(태그)를 가져오는 방법
Element(변수).value : input 태그에서 value 값을 가져올때 사용하는 방법
<body>
<input type="text">
<button id="btn">클릭</button>
<script>
// Element(변수).innerHTML : 열리고 닫히는 태그의, content 영역의 텍스트(태그)를 가져오는 방법
// Element(변수).value : input 태그에서 value 값을 가져올때 사용하는 방법
// id의 ="값"을 써줌
let btn = document.getElementById('btn');
// input의 선택자를 써줌 (예시 : id:#, class:.)
let input = document.querySelector('input');
btn.onclick = () => {
console.log("실행!", input.value);
alert(input.value);
// input 태그의 내용 비우기
input.value = '';
}
</script>
</body>
<body>
<input type="text" id="inputTag">
<button id="inputBtn">input태그 값 가져오기</button>
<br>
<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAFwAXAMBIgACEQEDEQH/xAAaAAADAQEBAQAAAAAAAAAAAAADBAUCAQYA/8QANBAAAgEDAwEGAgoDAQEAAAAAAQIRAAMhBBIxQQUTIlFhcYGhBiMyQpGxwdHh8BRS8VMz/8QAFwEBAQEBAAAAAAAAAAAAAAAAAAEDAv/EABwRAQADAQADAQAAAAAAAAAAAAABAhEhEiJRMf/aAAwDAQACEQMRAD8A9SLsqveZYdV4ri3Fc7RhY5ahKyB/EwE8eLn1oqr3kR4hHK1BtlOyUksOVH81i3bdUHeKd7fe8h/TXNjKJ3EHzI6evlW1uOnSQRwaDVtWDQJZSB4Zkx50S7bVlUOvHwmhFtzKrIQD05n4187PxayAIDGPw96Ab6H/AMXgH7rZpgFgsZMCIoU7CpJWeBFbD8c/GqNMVIQgkr59K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y2gG0NiRPOao/9k=" alt=""
width="200px">
<br>
<button id="getImg">이미지 값 불러오기</button>
<button id="setImg">이미지 변경하기</button>
<script>
// 1. input 태그 내에 사용자가 입력한 값을 가져오자!
// 2. 가져온 값을 콘솔창에 출력하기
let input = document.getElementById('inputTag');
console.log(input);
document.getElementById('inputBtn').addEventListener('click', ()=>{
console.log(input.value);
input.value = "";
})
// 3. 이미지 태그에 접근하고 수정해보자!
document.getElementById('getImg').addEventListener('click', () => {
//console.log("이미지 가져오기 버튼 실행!");
// 3-1) 현재 img태그에서 속성 값을 출력
let img = document.querySelector('img');
console.log(img);
// Case 1. getAttribute('속성이름')
console.log(img.getAttribute('src'));
// Case 2. 속성이름
console.log(img.width);
})
// 4. 현재 이미지 다른 이미지로 변경
document.getElementById('setImg').addEventListener('click', function(){
console.log('이미지변경 버튼 ');
let img = document.querySelector('img');
// Case1 : setAttribute('속성이름', '바꿀 값')
img.setAttribute('src', 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEAAkGBwgHBgkIBwgKCgkLDRYPDQwMDRsUFRAWIB0iIiAdHx8kKDQsJCYxJx8fLT0tMTU3Ojo6Iys/RD84QzQ5OjcBCgoKDQwNGg8PGjclHyU3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3Nzc3N//AABEIAKgAqAMBIgACEQEDEQH/xAAbAAABBQEBAAAAAAAAAAAAAAAEAQIDBQYAB//EADcQAAIBAgQEBAQFBQACAwAAAAECEQADBBIhMQUTQVEiYXHwgZGhsQYUMsHRI0JS4fEkMxUlQ//EABgBAQEBAQEAAAAAAAAAAAAAAAECAAME/8QAIREBAQADAQACAgMBAAAAAAAAAAECESExA0EEIhJRYRP/2gAMAwEAAhEDEQA/ANbatnMkyT1MCKJspLCJnbKRUi2ZbUQQICA9O9EJbicyxPWNflXiekxOdLIeXk3nL0+FSvlKlgWJXaBpSAFrkAwVEgg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rQSzZA1Yqdz/cepqTnqieHRdp7R+9dXVmUPEOJM6BLFweHcBYk9dOlVa33UEM7k2wEkiJPYfP3FdXV0niaiuXUsJHha82rMNgeoH81S42/JOhEmNKSuq/ofYGzZ/N3GDOyIDqVEk1bYLCWrbygKDXf0711dUmiktLlYlvEzEiemv31p4UxkuAsFJ0ncd66upSns2DiFVVDG6dZLRPejbWBU2s91uWyeJiWESdiTOkfzSV1TVSLfDYG1hw2W6l9suaILaDvGgpcG1q1cLYk2zYjKCdRmgkT1+PnXV1TV54yXhOLYC1j7Rt2CrKLZyWssJtIlmk6EjXprrWc/BfDmPEbq30GdXysBEaHUe+1dXVMvsc9/tptcP+asv+ZdPDfJXL/hB3Oukz9KvsMHU867qwWVA2A6feurqmO0RFj4yCZZiNRXV1dVl//9k=')
// Case2 : .속성이름 = '바꿀값'
img.width = '300';
})
</script>
</body>
<body>
<input type="text">
<button>변경!</button>
<br>
<br>
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSgw45QTKzgHw8u-25l_DvCmfFGazuojBlSZg&usqp=CAU"
alt="" width="500px">
<script>
// 1. 사진을 두개 구한다.
// 계곡 사진
let img_src1 = "https://www.kagoshima-kankou.com/storage/tourism_themes/15/responsive_images/29jfAXG0X89lvGo6zqwqTw3CxbD7vIqierH44aFE__1673_1115.jpg"
// 제주도 사진
let img_src2 = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSgw45QTKzgHw8u-25l_DvCmfFGazuojBlSZg&usqp=CAU"
// 2. 사용자가 input태그 안에 입력 값을 감지 -> console창에 띄우기
let input = document.getElementsByTagName('input')[0];
let img = document.querySelector('img');
// 3. 변경! 이라는 버튼을 눌렀을때 입력한 값에 맞게
// 사진을 배치해주세요 !
document.querySelector('button').addEventListener('click', function() {
console.log("버튼 클릭확인 : ",input.value);
// 4. ex) '양파쿵야' -> 양파쿵야 사진, '주먹밥쿵야' -> 주먹밥 쿵야 사진으로 변경
if(input.value == '계곡'){
console.log("계곡 사진으로 변경 : ",input.value);
img.src = img_src1
} else if(input.value == '제주도'){
console.log("제주도 사진으로 변경 : ",input.value);
img.setAttribute('src', img_src2)
} else {
console.log("잘못된 입력 값 : ",input.value);
// 5. 이외 다른 텍스트 입력시, alert 잘못 입력하셨습니다! 라고 띄워주기!
alert(input.value + " 값은 잘못 입력하셨습니다 !")
}
})
</script>
</body>