Is there a way to use $(this) inside jQuery functions?
HTML
<ul>
<li class="delete"><a onclick="deletePerson(12);" href="">Delete</a></li>
</ul>
jQuery
function deletePerson(id) {
$(this).parent().remove(); // doesn't work
// [...]
return false;
}
You can use
.call()to set the value ofthisas you requested.Now in the
deletePersonfunction,thiswill be the element.