In the below code how to pass the div object inside validate function
<div><input type="text"></input>   <a href="#" onclick="validate("Hot to pass the div objevt here")"</input>
<script>
function validate()
{
.....
.....
Finally remove the div
}
</script>
HTML:
javascript:
In the
validate()function,elemwill represent the<a>element that received the event.Then you can wrap it in a jQuery object, and use
.closest()to get the first<div>ancestor, and use.remove()to remove it from the DOM, and clean up any data attached, like event handlers.Or perhaps preferable to have jQuery take care of your event handlers:
HTML:
jQuery: