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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:10:27+00:00 2026-05-15T23:10:27+00:00

I have explained the problem below this code <div id=’content’> <div id=’help’> blah blah

  • 0

I have explained the problem below this code

<div id='content'>

<div id='help'>
blah blah blah
once there lived a king named midas
blah blah blah
</div>

<script>
$(document).ready(function() {
    $('#help').click( function () {
          $('help').hide(500);
     })
})
</script>

<!-- bottom of the page after a long other content -->
</div>
<!-- end of div id= content -->

<script>
function ondelete()
{
// doing an ajax request to after deleting some items to dynamically update a list.
// the result will also have the same above div code with that help div
   document.getElementById('content').innerHTML = xmlHTTP.responseText
}
</script>

There is a content part inside a div which has ‘content’ as its id
Inside that i have a help div.
Which is display:none bydefault and if the user clicks the help button i do a

$('#help').show(500);

and when the user clicks the same help button or if the user clicks inside the help div then i do this code to hide that div $(‘#help’).hide(500)

This is working well until i do an ajax request to update the content of div id=’content’
I am overwriting the same help div with the same content. it is like i am overwriting
the entire content area except the header and the footer.

but after updating it with the response text the click event at the top of code which is inside the document.ready is not working where as onclick is working on that div

i mean is working well.
without that on click and with that above document ready code it is not working when overwritten from ajax.

From my experience javascript code or links is not working when a code with script src tags and script tags are dynamically fetched and updated using ajax.

Now i am using onclick instead of that document ready to hide and show the help div.

and above all

when there is a overwrite from ajax if you again set
$(#'help').click = .... code
this works.

like 
function ondelete()
{
   document.getElementById('content').innerHTML = xmlHTTP.responseText
   $('#help').click (function() { $('#help').hide(500); });
}

so it seems that you have to update all the attached events when you update it using ajax.

Please put your comments and suggestions to overcome this.

  • 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-05-15T23:10:28+00:00Added an answer on May 15, 2026 at 11:10 pm

    try using .live().

    $(document).ready(function() {
        $('#help').live('click', function () {
              $(this).hide(500);
         });
    });
    

    .live( eventType, handler )

    as of version 1.9, .live() has been deprecated.

    You then can use http://api.jquery.com/delegate/

    Attach a handler to the event for all
    elements which match the current
    selector, now or in the future.

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

Sidebar

Related Questions

All, See the code below: function menu() { this.menuitem=[]; this.submenu=[]; this.menuitem[0] = $('div#sivname1'); this.menuitem[1]
I am using the below example code and have a problem where I can't
Here a small piece of code for testing and explain the problem. I have
I have some code I that although it works, its making my content erratic.
This problem has been bothering me for sometime now, I have not settled on
Hello I have a problem with the following code in a GTMTestCase: - (void)testSomething
I have this code, which uses ob_start php function. Which basically puts the echoed
I hoping someone out there can help me out with a Jquery problem I'm
I have this problem to solve that I have no idea how to do
I have a problem concerning a HashMap in Java. To explain the problem in

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.