t4t5 / sweetalert

A beautiful replacement for JavaScript's "alert"
https://sweetalert.js.org
MIT License
22.4k stars 2.84k forks source link

Display a list of items? #817

Open eminx opened 6 years ago

eminx commented 6 years ago

Hi, I want to allow users make a search and then show the results on a list within the same sweetalert modal window. How can I do that? Inserting in complex DOM nodes feels quite difficult, or I just couldn't manage it :)

keithort commented 6 years ago

You can generate a node for the list like so: const list = document.createElement('ul'); const listItem = document.createElement('li'); listItem.innerHTML = 'I am your content'; list.appendChild(listItem);

then in your call for sweet alert:

content: list,