Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8093041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:25:00+00:00 2026-06-05T20:25:00+00:00

I need to bind to an event (say a click on an arbitrary <input>

  • 0

I need to bind to an event (say a click on an arbitrary <input>) inside an iframe that is created dynamically after the user performs a certain action. The code that appends the iframe AND the code inside the iframe is not mine and I cannot change it in any way (this is a CMS admin panel).

How can I listen to the events using jQuery 1.6 (again, this is not my choice, I’m stuck with it). I thought delegate() might be what I want:

$('body').delegate('iframe input', 'click', function(e) {
    alert('bingo?');
});

But the above does not alert when an input is clicked. The below, however, works as expected:

$('body').delegate('input', 'click', function(e) {
    alert('bingo?');
});

But this is outside the iframe.

The src of iframe points to the same domain, obviously.

Any help or just a prod in the right direction is greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:25:02+00:00Added an answer on June 5, 2026 at 8:25 pm

    This 'iframe input' does not selects input elements inside the iframe.

    You can bind the event like

    $('body iframe').contents().find('input').bind('click',function(e) {
        alert('bingo?');
     });
    

    I think You can also use something like

    $('body iframe').contents().find('body').delegate('input','click',function(e) {
        alert('bingo?');
     });
    

    To detect if the iframe has been fully loaded, use the method described in this answer
    https://stackoverflow.com/a/5788723/344304

    Add In the main/parent document:

    function iframeLoaded() {
        $('body iframe').contents().find('input').bind('click',function(e) {
            alert('bingo?');
         });
    }
    

    Add In the iframe document:

    window.onload = function() {
        parent.iframeLoaded();
    }
    

    Or use

    $('body iframe').load(function(){
         $('body iframe').contents().find('input').bind('click',function(e) {
                alert('bingo?');
             });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to bind width property of the GridView column that is created dynamically
I need to dynamically bind() the click event, but the problem is when I
I've a table that contains 3 columns. I need to bind an event that
I have a situation where I need to bind a click event to an
I need to bind event listener to all dynamicaly created elements by given css
In the below code, after success need to bind the click and should fire
I have the following markup which I need to bind a click event to
I need to bind a keypress event to a form of elements that is
I'm looking to find the Javascript Event I need to put into jQuery's .bind
I bind keyDown , keyPress and keyUp events to a text input. I need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.