Coding
[JAVA SCRIPT] function, onclick
이즈 life
2021. 9. 3. 22:33
JAVA SCRIPT는 컴퓨터가 유일하게 알아들을 수 있는 프로그래밍 언어이다.
//<style> 하단부에 작성한다.
<script>
function hey() {
alert('안녕!!');
}
</script>
//function은 javascript에서 기능을 넣어주는 명령어다.
<body>
<div class="jumbotron">
<h1 class="display-4">나홀로 링크 메모장</h1>
<p class="lead">중요한 링크를 저장해두고, 나중에 볼 수 있는 공간입니다.</p>
<hr class="my-4">
<p class="lead">
<a onclick="hey()" class="btn btn-primary btn-lg" href="#" role="button">포스팅박스 열기</a>
</p>
</div>
</body>
// onclick="hey()"의 기능을 '포스팅박스 열기' button에 적용하면서 button click시 hey()의 결과인 안녕!!이 출력된다.
추가적으로 localhost로 접속하여 검사하기(Control + U)하여 console에서도 실행해 볼 수 있다.
마우스 오른쪾 버튼 - 검사하기(ctrl + u) - Console - hey() enter - function 실행