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

  • SEARCH
  • Home
  • 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 8036849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:45:20+00:00 2026-06-05T02:45:20+00:00

I am adding content in the iframe dynamically and that content are binded with

  • 0

I am adding content in the iframe dynamically and that content are binded with an event using .live() function :

           <body>
            <div id="container">
               <iframe id="if" src="something"></iframe>
            </div>

            <script>
             /* binding event */
             $(document).ready(function() {
               $("p").live("mouseover", function() { /* do something */ });
             });

             /* appending content */
              $("#if").contents().find("#someid").append("<p></p>");                  
            </script>
           </body>

The p tag added successfully but the event is not executed on mouseover. Whats the problem?

Note : I can`t add the binding event script inside the iframe.

  • 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-05T02:45:22+00:00Added an answer on June 5, 2026 at 2:45 am

    Your live binding is only for the main document not for the iframe. Did you try following?

    With jQuery 1.4 and above use jQuery delegate:

    $("#if").ready(function() {
        $("#if").contents().delegate("p", "mouseover", function() {
            // do something
        });
    });
    

    With jQuery 1.7 and above use jQuery on:

    $("#if").ready(function() {
        $("#if").contents().on("mouseover", "p", function() {
            // do something
        });
    });
    

    Also see the example for delegate() or example for on(): after the “mouseevent loaded” alert hover the cloud image.

    P.s.: this will target all <p> within the iframe. But the iframe will only parsed if it is not a violation of the browser’s cross-site policy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a TableLayout that I am dynamically adding content to in code in
I am using post message to adjust the height of an iframe dynamically. The
I'm using the jQuery UI dialog to present content in a new iFrame. Everything
I am currently dynamically adding content to the page with the help of Jquery.
I am using bash with linux to accomplish adding content to the top of
I am using jQuery Mobile with jQuery Mobile Router , to dynamically change content
I'm adding css-based tab navigation to a site that is still using table-based layout.
I'm working on adding content to a web-page with javascript. The problem is that
I am using ckeditor in phpbb. when adding content in my post page. I
I need to write to a very large text file by adding content to

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.