<button type="button" onclick="myFunction()">클릭하세요.</button>
<button type="button" onmouseover="myFunction()">마우스를 올리세요.
</button>
<button type="button" ondbclick="myFunction()">더블클릭하세요.</button>
function 함수명(){
document.getElementById("id명").innerTEXT="글자~~";
document.getElementById("demo").innerHTML
="<span style='color:red;'>글자</span>";
}
"<span style='color:red;'>글자</span>" - "<></>" 이면 style 안 은 ' (홑 따옴표)를 사용해야 한다. - '<></>' 이면 style 안은 " (쌍 따옴표)를 사용해야 한다. 같은 등호를 사용하고 싶을 경우 \을 붙여서 사용하면 된다.
head 내의 위치
-> html의 해석순서가 위에서 부터 내려오므로 함수만 적용 가능하다.
-> window.onload 를 사용할 경우 함수 외에도 적용 가능
body 맨 마지막의 위치
<script type="text/javascript">
function 함수명(){~~~}
</script>
<script type="text/javascript" src="상대주소"></script>
window.onload = function(){
~~~~
}
function 함수명(){
document.write("")
}
funciton 함수명(){
window.alert("알림창 글씨");
/* 또는 */
alert("알림창 글씨");
}
01_where_to
-> 01_javascript_in_head.html, 02_javascript_in_body.html, 03_javascript_external_file.html, 04_window_onload_1.html, 05_window_onload_2.html, 03.js, 05.js
02_output
-> 01_innerHtml.html, 02_document_write.html, 03_window_alert.html, 04_console_log.html, 01.js, 02.js, 03.js, 04.js