Content

Board ID 658
Writer heojk
Write Date 2017-04-28 16:55:54
Subject [Re]자바스크립트 이벤트 처리하기 - JS 파일
Content css_event.js
var redButton = document.querySelector("#redButton");
var greenButton = document.querySelector("#greenButton");
var blueButton = document.querySelector("#blueButton");
var textField = document.querySelector("[type=text]");
var button1 = document.querySelector("[type=text] + [type=button]");
var result1 = document.querySelector("#result1");
var file = document.querySelector("[type='file']");
var button2 = document.querySelector("[type='file'] + [type='button']");
var result2 = document.querySelector("#result2")

redButton.addEventListener("click", function() {
	document.querySelector("body").setAttribute("bgcolor", "red");
});
greenButton.addEventListener("click", function() {
	document.querySelector("body").setAttribute("bgcolor", "green");
});
blueButton.addEventListener("click", function() {
	document.querySelector("body").setAttribute("bgcolor", "blue");
});

button1.addEventListener("click", function() {
	result1.textContent = textField.value;
});

button2.addEventListener("click", function() {
	result2.textContent = file.value;
});