Currently, I am facing an issue with a function I have implemented. This function adds a blur effect to words in a Blockquote when the page is loaded. However, I need this function to work for all Blockquotes and different divs on the page, not just the top one in the HTML. I have tried searching for solutions but haven't been successful in finding one that works or that I fully understand.
Can anyone provide guidance on how I can resolve this issue?
function splitWords() {
let quote = document.querySelector("blockquote q");
quote.innerText.replace(/(<([^>]+)>)/ig,"");
quotewords = quote.innerText.split(" "),
wordCount = quotewords.length;
quote.innerHTML = "";
for (let i=0; i < wordCount; i++) {
quote.innerHTML += "<span>"+quotewords[i]+"</span>";
if (i < quotewords.length - 1) {
quote.innerHTML += " ";
}
}
quotewords = document.querySelectorAll("blockquote q span");
fadeWords(quotewords);
}
function getRandom(min, max) {
return Math.random() * (max - min) + min;
}
function fadeWords(quotewords) {
Array.prototype.forEach.call(quotewords, function(word) {
let animate = word.animate([{
opacity: 0,
filter: "blur("+getRandom(2,5)+"px)"
}, {
opacity: 1,
filter: "blur(0px)"
}],
{
duration: 1000,
delay: getRandom(500,3300),
fill: 'forwards'
}
)
})
}
splitWords();
.border {
width:100%;
height:300px;
background-color:#b2800a;
min-width:1200px;
}
.borderimg {
width:100%;
content:url("border.png");
min-width:1200px;
}
.background
{
width:100%;
content:url("Background.png");
}
body {
background-color:#b2800a;
padding:0;
margin: 0;
min-width:auto;
}
.header
{
position:absolute;
font-size:70;
color:white;
left 1000px;
opacity: 0.7;
}
*
{
box-sizing: border-box;
}
blockquote {
font-size: 3rem;
}
blockquote q {
font-family: Georgia, serif;
font-style: italic;
letter-spacing: .1rem;
}
blockquote q span {
will-change: opacity, filter;
opacity: 0;
filter: blur(0px);
}
q {
quotes: "“" "”" "‘" "’";
}
q:before {
content: open-quote;
margin-right: .8rem;
}
q:after {
}
q:before, q:after {
color: #ccc;
font-size: 4rem;
}
.text1 {
font-size:80px;
top:160px;
color:white;
position:absolute;
opacity: 0.7;
}
<html>
<head>
<script type="text/javascript" src="javascript.js"></script>
<link rel="stylesheet" href="style.css" type="text/css">
<title>Name</title>
<body class="body">
</head>
<div class="header"><blockquote><q>Creativity is my way to say hi</q></blockquote></div>
<div class="text1"><blockquote><q>Welcome on my site</q></blockquote></div>
<script type="text/javascript">
splitWords();
</script>
<div class="background"></div>
<div class="borderimg"></div>
<div class="border"></div>
</body>
</html>