Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attach click handler even on element inside iframe with jQuery

Tags:

jquery

iframe

How can I attach a click event handler to an element inside an iframe?

Here's what I tried and doesn't work:

$("#parent iframe").contents().find("a").live("click", function () {
    alert ("test");
    return false;
});

The iframe is on the same domain.

like image 878
Jourkey Avatar asked Oct 31 '09 23:10

Jourkey


1 Answers

Discovered the problem. LIVE does not work inside an iframe. Switching to bind works fine. Will do manual event delegation instead.

like image 135
Jourkey Avatar answered Oct 14 '22 19:10

Jourkey