How to remove an item by clicking on a button?

  • 0
    There is a div with a text button
    <div id="elem1">
    			Этот текст нужно удалить
    			<button id="elem1" onclick="deletedItem()">Удалить</button>

    On clicking on the button, I think you need to call the function to remove the div with the desired id. I called it deletedItem ()
    But there is such a moment.
    These divs can be in N number and the div's id will always be different.
    I.e. It is necessary to somehow pass the id of the button to the deletedItem () function (the id of the button matches the id of the div that needs to be deleted).
    How can this be done?
    The intended function itself:
    function deletedItem(idItem) {
    JavaScript Addison West, Aug 24, 2020

  • 1 Answers
  • 0

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!