javascript - On adding the click event tracker using jquery on the document, the click event on a link is not working -
i have file listing , there option delete file. on clicking delete asks confirmation. on clicking confirm file deleted. please check jsfiddle that
when add html click handler inorder change confirm text original delete text,
$('html').click(function(event){ if($('.confirmdelete').is(':visible')){ $('.confirmdelete').hide(); $('.deletelink').show(); return false; } }); $('.confirmdelete').hide(); $('.deletelink').click(function (event) { $(this).hide(); $('.confirmdelete').filter(':visible').each(function () { $(this).hide(); $(this).prev('.deletelink').show(); }); $(this).next('.confirmdelete').show(); event.stoppropagation(); return false; });
but issue on clicking 'confirm' text not going href hiding confirm text , showing delete text.
try instead of html
, document
.
$(document).not(".confirmdelete").click(function(event){ if($('.confirmdelete').is(':visible')){ $('.confirmdelete').hide(); $('.deletelink').show(); return false; } }); $('.confirmdelete').hide(); $('.deletelink').click(function (event) { $(this).hide(); $('.confirmdelete').filter(':visible').each(function () { $(this).hide(); $(this).prev('.deletelink').show(); }); $(this).next('.confirmdelete').show(); event.stoppropagation(); return false; });
fiddle: https://jsfiddle.net/945j4g0x/
Comments
Post a Comment