You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
425 B
JavaScript
20 lines
425 B
JavaScript
const sentences = Array.from(document.querySelectorAll("span"));
|
|
|
|
console.log(sentences);
|
|
|
|
sentences.forEach((sentence) => {
|
|
let content = sentence.textContent.trim();
|
|
|
|
if (content) {
|
|
let first = content[0];
|
|
let rest = content.substring(1);
|
|
sentence.innerHTML = rest;
|
|
|
|
let capital = document.createElement("span");
|
|
capital.classList.add("first");
|
|
capital.innerHTML = first;
|
|
|
|
sentence.prepend(capital);
|
|
}
|
|
});
|