I assume you mean something like this
https://jsfiddle.net/2spe18bt/
Then it’s just to adjust it to however you use it.
If you already depend on jquery you can simplify the toggle and append functions.
If you want the list to slide up/down you can just add some css
If you want the list in a modal then show a modal and display the ingredients in it.
etc
const button = document.querySelector('button'),
list = document.querySelector('ul')
button.addEventListener('click', toggleList)
function toggleList() {
const listIsDisplayed = window.getComputedStyle(list).display === 'block'
list.style.display = listIsDisplayed ? 'none' : 'block'
}
const recipe = {
name: 'Something good',
ingredients: [
{ ingredient: '1/2 cup milk' },
{ ingredient: '1 cup of stuff' },
{ ingredient: '1 pinch of this' }
]
}
document.querySelector('h1').innerHTML = recipe.name
recipe.ingredients.forEach((ingredient) => {
var ingredientElement = document.createElement('li');
ingredientElement.innerHTML = ingredient.ingredient;
list.appendChild(ingredientElement)
})
</script>