I`m having problem with converting my code from OOP to Function. Please show me a way. Thanks a lot.
const basket = document.querySelector('.basket_icon');
basket.addEventListener('click', chartVisblity);
function chartVisblity() {
const chart = document.querySelector('.chart');
const visbl = chart.style.display;
if (visbl === "block") {
chart.style.display = "none"
} else {
chart.style.display = "block";
}
}
Excluding the usage of the DOM Model, your code is in the form of a function, and it is not Object Oriented in the sense that it uses a method of an object class instead of an independently defined function.
It seems like you've already achieved your goal!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.