Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Issue Exiting Function

Featured Replies

I have this script which loads content from another page.

$(".load").click(function () {
    $("#projects").html("");
    $("#loading").show();
    $("#projects").load("projects.html #"+$(this).data('id'), function () {
        $("#loading").hide()
    })
})

Once the content has been viewed, I'm wanting to have a link which closes the content. I've tried the following:

$(".exit").click(function () {
    $("#projects").hide();
})

Which works, but once it's clicked the content can't be viewed a second time. I tried trying to end the script with a return but can't seem to get it working.

What version of jQuery do you use?

 

I'm assuming it's because the elements don't exist in the DOM until after the AJAX call, so instead of using click(), you could try:

 

$(document).on('click', '.exit', function() {
 // do your stuff
});

Or the following (for jQuery versions 1.6 and below):

 

$('.exit').live('click', function() {
 // do your stuff
});

Reference here:

 

https://api.jquery.com/on/

https://api.jquery.com/live/

  • Author

I'm using the latest version of jQuery, however getting the same result with your first suggestion.

 

If I click the exit link first it just stops the other function from working until the page is reloaded. If i click it after the content has been loaded it does hide the content, but again stops the other function from working.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.