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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:59:37+00:00 2026-06-05T14:59:37+00:00

im a js noob . i have ` with this my hidden div shows

  • 0

im a js noob . i have `
with this my hidden div shows up but the ajax not, with the second the ajax works but shows up directly – i would like to include a click event on the ajax script but dont know how to:

$(document).ready(function(){
   $(".project-thumbnails a").click(function(event){
    event.preventDefault();
    $('#project-container').slideDown('slow');
    return false;
   });

   $('a.project-close').click(function(event){
    event.preventDefault();
    $('#project-container').slideUp('slow');
    return false;
   });

});

and

jQuery(document).ready(function($) {

    var $mainContent = $("#project-container"),
        siteUrl = "http://" + top.location.host.toString(),
        url = ''; 

    $(document).delegate("a[href^='"+siteUrl+"']:not([href*=/wp-admin/]):not([href*=/wp-login.php]):not([href$=/feed/])", "click", function() {
        location.hash = this.pathname;
        return false;
    }); 
    $("#searchform").submit(function(event) {
        location.hash = '?s=' + $("#s").val();
        event.preventDefault();
    }); 
    $(window).bind('hashchange', function(){
        url = window.location.hash.substring(1); 
        if (!url) {
            return;
        } 
        url = url + " .entry"; 
        $mainContent.animate({opacity: "0.1"}).html('').load(url, function() {
            $mainContent.animate({opacity: "1"});
        });
    });
    $(window).trigger('hashchange');
});

how can I combine those to snippets that finally the DIV with the AJAX opens up only after I click on it and is it possible to close it?

  • 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-05T14:59:38+00:00Added an answer on June 5, 2026 at 2:59 pm

    The first solution would be to use delegated events (.delegate() or .on() with a selector). Instead of registering the handler on the links themselfes, register it on an element that is not overwritten/reloaded/added by the ajax script, and it will work for later appended elements too.

    The second solution would be to execute the function that registers the handlers not (only) onDOMready, but onHashchange. This event is triggered by your ajax script to indicate that there is new content. Yet with that solution you’d need to prevent the code registering a handler twice on the same element, so you should use the first one.

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

Sidebar

Related Questions

This kind of seems like a noob question, but I could not find an
I'm a noob so this is probably basic stuff, but I have tried to
Noob question here! I have an array with hashes that looks like this: arr
This may sound like a noob question, because it is. I have tried for
I have this (noob?) question, but i just can't figure it out for many
I know this may have a simple solution but I'm a Jquery noob. Please,
I'm a noob in jQuery and have stuck at this. I have the following
Please enlighten this flex noob. I have a remoteobject within my main.mxml. I can
This is a question from a Java noob. I have eclipse open (JRE 1.6),
Please excuse the noob-ish nature of this question. I have a project in which

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.