Use a common modal for different scenarios on the entire web page

Viewed 81

I am opening a modal on the click of different elements(buttons) on my webpage.

Is there a way to have only one modal, and control its view depending on which element it is being triggered from?

Each modal is going to have different content displayed.

For example,

  • Modal A will display a form consisting of 10 different fields
  • Modal B will display a "Thank you" message
  • Modal C will display another form consisting of just 3 fields

Different buttons trigger different modals.

I was hoping to have the code for the common modal be placed at the start of the body, and somehow alter its view using Javascript. But I am not sure how to do that.

I will not be using JQuery!

0 Answers
Related