This question has already been answered:

There is a JS function:

function removeServiceItem() { $(this).parent().remove(); } 

When it starts, nothing happens, what's the error? HTML:

 <button>Элемент <span onclick="removeServiceItem()">Убрать</span></button> 

Reported as a duplicate at Grundy. javascript Oct 26 '17 at 2:40 pm

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • console.log(this); - Igor

1 answer 1

 function removeServiceItem(element) { console.log(element); $(element).parent().remove(); } 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <button>Элемент <span onclick="removeServiceItem(this)">Убрать</span></button>