Ask Your Question

How can the style of the loader be modified while the form submission is being processed?

asked 2023-03-28 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-11-14 00:00:00 +0000

ladyg gravatar image

This can be achieved by modifying the CSS of the loader element using JavaScript or jQuery. The following steps can be followed:

  1. Create a loader element in HTML with its own CSS styles.

  2. Add a CSS class to the loader element that sets it to display: none.

  3. When the form is submitted, use JavaScript to remove the display: none class from the loader element so that it becomes visible.

  4. Modify the CSS styles of the loader element using JavaScript or jQuery to change its appearance, such as the color or size.

  5. Once the form submission is complete, use JavaScript to add back the display: none class to the loader element to hide it again.

Example code:


<div id="loader" class="hidden">
  <i class="fa fa-spinner fa-spin"></i>


.hidden {
  display: none;

#loader {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  color: #fff;
  font-size: 3rem;


const form = document.querySelector('#my-form');
const loader = document.querySelector('#loader');

form.addEventListener('submit', function() {
  loader.classList.remove('hidden'); = '#f00';

// after form submission is complete:
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2023-03-28 11:00:00 +0000

Seen: 19 times

Last updated: Nov 14 '22