Home > database >  Create a javascript pop-up with createElement
Create a javascript pop-up with createElement

Time:02-23

I would like to create a pop-up when I press "details". I don't know how to deal with "createElement".

let ul = document.createElement('ul');

let detail = document.createElement('details');
detail.appendChild(ul); // element du detail

let summary = document.createElement('div');
summary.appendChild(detail);

let colDetail = document.createElement('td');
colDetail.className = 'td-detail';
colDetail.appendChild(summary);
<th>Détails</th>

CodePudding user response:

You can use .addEventListener() or .onClick methods on element.

CodePudding user response:

You can look into jquery popup overylay plugin.

https://dev.vast.com/jquery-popup-overlay/

The instructions on how to make an overlay popup are great.

CodePudding user response:

A popup in the page is called a modal. The easiest way to do it is not to create the new element, but rather have it all along with a CSS-class that is hidden:

.nodisplay {
    display: none
}

Then you hide or show it removing the class with

element.classList.add('nodisplay')

or

element.classList.remove('nodisplay')
  • Related