I have a div class called 'cat'. In mouseover event another div is displayed with two anchor link on which click event are hard coded. Now when anchor is clicked its parent div click also gets fired. I tried to return galse, but it is not working. The code is as below
function onload()
{
$('.cat').css('cursor', 'pointer');
$('.cat').mouseenter(function (e) {
$('<div />', {
'class': 'tip',
html: 'Name: ' + $(this).data('cat-name') + '<br/>Web Name: ' + $(this).data('web-name') + '<br/>Total No. Of SubCategories: ' + $(this).data('total-subcategory') + '<br/><br/><a href="#" onclick = "return addsubcategory(' + $(this).data('cat-id') + ',this)">Add Sub Category</a> <a href="#" onclick = "editcategory(' + $(this).data('cat-id') + ',this)">Edit Category</a> ',
css: {
position: 'fixed',
top: e.pageY,
left: e.pageX,
border: '1px solid red',
background: 'yellow',
padding: '5px',
font: '8'
}
}).appendTo(this);
});
$('.cat').mouseleave(function (e) {
$('.tip', this).remove();
});
$('.cat').on('click', getsubcategory);
}
function getsubcategory()
{
var clicked = $(this).parent().attr('id');
gatsubcategory(clicked);
return false;
}
function editcategory(catid,e) {
alert("Edit " + catid);
return false;
}
function addsubcategory(catid,e) {
alert("Add " + catid);
return false;
}