Can someone explain what's the difference between event.preventDefault()
and event.stopPropagation()
?
I have a table and within that table I have an img tag.
When I click the img tag, I want to see a popup.
But I also want to stop the selection of multiple rows, so I use:
$("table.items tbody tr").click(function(event) {
event.stopPropagation();
});
When I use the js code, the popup does not appear;
If I delete the js code, the popup works.
$(".info").live("click",function(e){
//console.log('ok');
e.stopPropagation();
var elem = $(this);
var id = $(this).attr("id").replace("image_","container_");
$('#'+id).toggle(100, function() {
if($(this).css('display') == 'block') {
$.ajax({
url: "$url",
data: { document_id:elem.attr('document_id') },
success: function (data) {
$('#'+id).html(data);
}
});
}
});
});
Why?
click
; usemousedown
. – Ziegler