feat: js
This commit is contained in:
11
articles/static/js/fold-post.js
Normal file
11
articles/static/js/fold-post.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const foldBtns = document.getElementsByClassName('fold-button')
|
||||
|
||||
for (const btn of foldBtns) {
|
||||
btn.addEventListener('click', function (event) {
|
||||
event.preventDefault()
|
||||
console.log('you clicked ', event.target)
|
||||
const div = event.target.parentElement.getElementsByClassName('one-post-content')[0]
|
||||
div.classList.toggle('hidden')
|
||||
btn.innerHTML = div.classList.contains('hidden') ? 'Показать' : 'Скрыть'
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user