1

I want to style the elements which are created after the form submission. The form itself is created by the JS script and I don't have access to it. I already managed to get it working using setInterval

Is there some better solution?

setInterval(function () {
 if (document.querySelector('.submitted-message')) {
 document.querySelector('.submitted-message').style.cssText = "display: flex; font-size: 20px"
 }
}, 100);
asked May 20, 2021 at 10:05
1
  • 1
    There is absolutely no problem with this. It is clearly readable Commented May 20, 2021 at 10:13

1 Answer 1

2

Yes. Create a CSS class that is loaded by default:

.someClass{
 color:red;
}

and when you create your new elements, make sure that their class attribute contains someClass.

EDIT It looks like the elements already have a class of submitted-message, so just create a CSS rule to target that class:

.submitted-message{
 display: flex; 
 font-size: 20px
}

right?

answered May 20, 2021 at 10:08
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.