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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:57:52+00:00 2026-05-23T14:57:52+00:00

I am using jQuery to allow my users to quickly go through their profiles.

  • 0

I am using jQuery to allow my users to quickly go through their profiles. They have an inbox on their profiles and I am letting them delete past messages using jQuery. The problem is that each time the page is loaded there will be a different number of emails. How can I tell jQuery to manage the function for mail1 and mail2 and mail 3 etc but only if they exists.

Below you will see the jquery I am running for each but there needs to be a loop of some kind.

$(document).ready(function() {
  $("#del1").click(function() {
    $(".mail1").fadeOut();
  });
});

$(document).ready(function() {
  $("#del2").click(function() {
    $(".mail2").fadeOut();
  });
});
  • 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-23T14:57:53+00:00Added an answer on May 23, 2026 at 2:57 pm

    You should make your elements and code more generic. For instance, give all delete links the same class, lets say deleteButton and all mails the same class, say mail.

    Then use their proximity to deal with them. Maybe something like this:

    $(".deleteButton").click(function(){
       $(this).parent().find(".mail").fadeOut();
    });
    

    This assumes that the button and the mail share a common parent, but even if they don’t, something similar can be done.

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

Sidebar

Related Questions

I'm using a CMS to allow users to add keywords to their profiles, but
Im using jQuery Markitup to allow users to input html... So they can input
I am using jquery-ui-tabs to allow users to create their own tabs, then ofcourse
I'm using Jquery to allow users to upload an image via Ajax in a
I am using a jQuery plugin called Stepy , to allow users to complete
I am using a jQuery plugin called Stepy , to allow users to complete
I am trying to create a GUI using jquery and html to allow users
I am using the jQuery plugin 'formwizard' and wish to allow users to jump
I'm using jquery UI AutoComplete to allow users to tag friends using @mentions. By
I'm using the ocupload plugin for jQuery to allow users of my app 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.