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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:24:46+00:00 2026-05-15T09:24:46+00:00

I have an emote selector that opens up when a user clicks an entry

  • 0

I have an emote selector that opens up when a user clicks an entry in a diary. The way I’ve worked it is that the emote selector panel lives hidden at the top of the page. When a user clicks on the ’emote control’ associated with an entry, I use JavaScript to grab the HTML of the emote selector panel from the top of the page and insert it next to the entry.

Using Firebug, here’s what the finished product would look like in the page (snippet from element inspect). I’m trying to get the ID for the class ’emote-control-container’ which contains the entry id:

<td>
    <div id="1467002" class="emote-select emote-default">&nbsp;</div>
    <div class="emote-control-container" id="emote-controls-1467002">
    <div id="emote-control-selector">
        <div id="emote-control-selector-body">
            <ul>
                <li id="emote-1"><img src="/images/default_emote.gif?1276134900" class="emote-image" alt="Default_emote"></li>
                <li id="emote-2"><img src="/images/default_emote.gif?1276134900" class="emote-image" alt="Default_emote"></li>
                <li id="emote-3"><img src="/images/default_emote.gif?1276134900" class="emote-image" alt="Default_emote"></li>
                <li id="emote-4"><img src="/images/default_emote.gif?1276134900" class="emote-image" alt="Default_emote"></li>
            </ul>
        </div>
        <div id="emote-control-selector-footer">
            &nbsp;
        </div>
    </div>
</div>
                    </td>

I need the entry ID along with the emote ID to make a post via AJAX when a user selects an emote from the selector panel by clicking on it.

I’m able to get the emote ID just fine with this, which I’m using to alert-out the selected emote ID:

  jQuery('li').live('click', function(e) { 
    e.preventDefault;
    var emoteId = this.id;
    alert(emoteId);
  });

I’m having trouble traversing up DOM to get the element ID from ‘.emote-control-container.

I’ve tried everything, but I’d expect this to work, but it doesn’t:

  jQuery('li').live('click', function(e) { 
    e.preventDefault;
    var entryId = jQuery(this.id).parent(".emote-control-container").attr("id");
    alert(entryId);
  });

What am I doing wrong.? I can’t target the ID of the .emote-control-container.

  • 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-15T09:24:47+00:00Added an answer on May 15, 2026 at 9:24 am

    You want .closest() here, like this:

    jQuery('li').live('click', function(e) { 
      e.preventDefault;
      var entryId = jQuery(this).closest(".emote-control-container").attr("id");
      alert(entryId);
    });
    

    The .parent(selector) call only gets the immediate parent if it matches the selector, it doesn’t keep going up until it finds it (which is a bit counter-intuitive). .closest(selector) does climb until it matches the selector, which is what you’re after.

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

Sidebar

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.