I have tried the following code:
$('a.buildMenu').click(function (event) {
// Prevent normal behaviour
event.preventDefault();
// Stops it bubbling to the document
event.stopPropagation();
var link = $(this);
$(document).find('div#' + $(link).data('id'), function() {
console.log($(link).data('id'));
$('.buildMenu').removeClass('selected');
$('.menu').remove();
return false;
});
Which basically means if a div with an id that matches the value of data-id on the clicked link then run the code. However the find method has no callback. How would I do this?
Thanks
You don’t need to wait for anything, right? So just use an if-statement: