I having some issue with a click event, if a user clicks on a link it will append a box to the body, and if a user clicks on the link inside the box it should remove the box but i dont. If I append the box outside the click event it works, but this isn’t what i want. I am doing something stupid i just know it but i cant seem to see what.
// inside the plugin wrapper
var obj = $(this);
obj.click(function(e){
$(body).append('<div id="thebox"><a href="#" id="thelink">a link</a></div>');
e.preventDefault();
});
$('#thelink').on('click',$(this),(function(e){
$('#thebox').remove()
e.preventDefault();
});
Should look like: