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 9195097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:33:30+00:00 2026-06-17T21:33:30+00:00

Page 1 <html> <head> <script src=jquery-1.8.3.js type=text/javascript></script> </head></head> <body><div id=main></div> </body> <script>$(‘div[id=main]’).load(‘page2.php’) $(‘span[id*=temp]’).on(‘click’,function(){ alert(this.id);

  • 0

Page 1

<html>
<head>
<script src="jquery-1.8.3.js" type="text/javascript"></script>
</head></head>
<body><div id="main"></div> </body>
<script>$('div[id=main]').load('page2.php')
$('span[id*=temp]').on('click',function(){
alert(this.id); }); //this block of code not working!!
</script>
</html>

Page 2

<div>
<span id="temp">
this is demo
</span>
</div>

Basically i want to load page2 again in main div when tag is clicked but am not able to fetch the id of the tag in page one,script of page1 not working for page 2 items or tags

  • 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-17T21:33:30+00:00Added an answer on June 17, 2026 at 9:33 pm

    You are trying to bind the event right after the AJAX call, so the element doesn’t exist yet. The call is asynchronous, so it doesn’t stop the code execution to wait for the response.

    Either bind the element after the content has loaded, using the success callback of the load method:

    $('div#main').load('page2.php', function(){
      $('span[id*=temp]').on('click', function(){
        alert(this.id);
      });
    });
    

    or use a delegate to bind the event to the parent element:

    $('div#main').load('page2.php');
    $('div#main').on('click', 'span[id*=temp]', function(){
      alert(this.id);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was using pyquery to construct a webpage: > page = PyQuery('<html><head><script type=text/javascript src=jquery-1.4.min.js></script><script
Take a look at this html: <head> <title>Test page</title> <script type=text/javascript> function submitForm() {
In my HTML-head i have this script included: <script id=mode type=text/javascript src=article.js></script> With a
<html> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8 /> <title>Untitled Document</title> <script type=text/javascript src=jquery.js></script> <script type=text/javascript
I have a page thusly: <html> <head></head> <body> <iframe src=local.html></iframe> <iframe src=http://www.google.com></iframe> </body> </html>
I've a page like this: <html> <head> <style type=text/css> #mainDiv{ height: 100%; } #myDiv{
I'm attempting to select all <script type=text/html> tags in a page. I use <script>
Edit: Entire page (HTML) <!doctype html> <html> <head> <meta charset=utf-8 /> <title>jQuery Ajax Test</title>
I want to add some style to head tag in html page using javascript.
I have this code This is the script in my head <script src=jquery.js></script> <script

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.