Hi!
I am trying to get some javascript working on a page that’s custom html, css and js.
When I try this code creating an index file everything works, but in Shopify it doesn’t.
The “placeholder” (label) text is supposed to go up when focusing input (works) and then get removed when you start typing (doesn’t work). The text just goes back down on top of the inputted text.
I don’t understand why it’s not working.
HTML in question:
CSS in question:
.placeholder-art {
color: #F5F5F7;
position: absolute;
top: 65px;
left: 40px;
transition: 0.3s;
pointer-events: none;
}
input[type=text]:focus + .placeholder-art {
top: 50px;
}
Working up until this point, js that isn’t working in Shopify, but works elsewhere:
const labelElement = document.querySelector(".placeholder-art");
const inputElement = document.querySelector("input");
inputElement.addEventListener("keydown", () => {
labelElement.style.display = "none";
});
You can find it here: https://galleryofai.com/pages/showcase-your-own-art
Note: This code is only for the first input field, the rest are similar
(Also border around input field is way bigger than specified when focused, still trying to get that smaller as well, but facing similar problems where it works in index file but not Shopify)
Any ideas what I could be doing wrong or not understanding?
Thanks