Using vanilla javascript and bulma.css, how can I unhide a span, make all the links in the span bold, then after a given amount of time (say, 1000 ms), take away the bold font weight. The first part, unhiding and making the links bold works fine using the following code:
function unhide_bold_unbold() {
mode_sents = document.getElementsByClassName('kanji-sent')
for (let i = 0; i < mode_sents.length; i++) {
mode_sents[i].classList.remove('is-hidden')
// Bold all links
links = mode_sents[i].getElementsByTagName('a')
for (let j = 0; j < links.length; j++) {
links[j].classList.add('has-text-weight-bold')
}
}
}
I tried adding the following at the end of the function, but it just delays the unhiding by 1000 ms, and the links never look bold.
sleep(wait_ms)
for (let i = 0; i < mode_sents.length; i++) {
links = mode_sents[i].getElementsByTagName('a')
for (let j = 0; j < links.length; j++) {
links[j].classList.remove('has-text-weight-bold')
}
}
...which uses the following function:
function sleep(milliseconds) {
const date = Date.now();
let currentDate = null;
do {
currentDate = Date.now();
} while (currentDate - date < milliseconds);
}
How can I make bulma's class update the font weight, then wait, then remove the bold font weight?
<span class="kanji-sent is-hidden"><a onclick="show_kanji_data('彼')">彼</a>等は皆、この<a onclick="show_kanji_data('曇')">曇</a>天に押しすくめられたかと思う程、揃って背が低かった。</span>