开发者

Detecting the clicked links after ajax load in Chrome using $("a:focus")

开发者 https://www.devze.com 2023-01-19 15:57 出处:网络
I have a page which has a list item, and each item has a delete button. Clicking the delete button loads the child page (delete.asp?id=123) in a hidden div.

I have a page which has a list item, and each item has a delete button. Clicking the delete button loads the child page (delete.asp?id=123) in a hidden div.

delete.asp has a javascript alert (on document ready) which succe开发者_StackOverflowssfully fires when the button is clicked. It also has $("a:focus").hide(); which removes clicked link. I can't seem to get this to work in Chrome. The alert fires but the link doesn't remove itself.

Besides using a:focus, is there a better way to do this?


Rather than removing the link from the loaded page, you should probably be removing it in the same event that loads the hidden page. Something like this:

$('a.delete').click(function() {
    //load delete.asp
    $('#myHiddenDiv').load('delete.asp?id=123');

    //hide the link
    $(this).hide();
});
0

精彩评论

暂无评论...
验证码 换一张
取 消