Notice
Recent Posts
Recent Comments
Link
Silver Library (Archived)
Call for a 'function' within a specific variable? 본문
Personal DB/Mainly for Front-end
Call for a 'function' within a specific variable?
Ayin Kim 2021. 9. 23. 23:33반응형
The core of this post is; how to call the function within the variable that has been already declared at the top.
Note: JS interacts to HTML. It reads the HTML document, then gives some change to it.
<!DOCTYPE html>
<html>
<head>
<title>How to call function within the variable?</title>
<meta charset="UTF-8" />
</head>
<body>
<div class="world">
<h2>Hello, World!</h2>
</div>
<script src="src/index.js"></script>
</body>
</html>
const greetingWord = document.querySelector(".world:first-child h2");
const wrapperTrigger = {
// function functionName() {
greetingWord.innerText = "example one to display"
}
functionName: function() {
greetingWord.innerText = "example one to display"
},
functionNameTwo: function() {
greetingWord.innerText = "nothing different"
}
};
// greetingWord.addEventListener("fullscreenchange", functionName);
greetingWord.addEventListener("fullscreenchange", wrapperTrigger.functionName);
greetingWord.addEventListener("blur", wrapperTrigger.functionNameTwo);
Reference: MDN
'Personal DB > Mainly for Front-end' 카테고리의 다른 글
Web Component 는 도대체 어떻게 사용할까? (0) | 2021.10.21 |
---|---|
[나만의 지식 DB] - 1. DOM 의 정의 (0) | 2021.10.15 |
Arrow function - key point (0) | 2021.09.21 |
모던 JavaScript 튜토리얼 (0) | 2021.07.10 |
react.js 와 API 로, 정보 사이트 UI 까지 구축하기 (0) | 2021.04.07 |