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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:54:32+00:00 2026-05-26T06:54:32+00:00

I have two tabs: In first tab I have a fixed list of items.

  • 0

I have two tabs:

  • In first tab I have a fixed list of items. Each item can be added to the other tab.
  • The second tab contains a custom list of items, originating from the first tab.
  • The second tab should only have items with unique IDs
  • It should not be possible to add the same item from tab1 to tab2 more than once.

The adding and removing mechanism works but the check that is made to see if an item has already been added to tab2 is not working. For now I’ve only alerted if the item is there or not.

If the check is made in the other direction, checking if an item exists in tab1 seems to be working fine which seems strange to me.

Can someone please suggest improvements to my code ?

EDIT:
The problem is that the check that is done always returns “No”. It needs improvements and I’m out of ideas.

HTML:

<div class="demo">
    <div id="tabs">
        <ul>
            <li><a href="#tabs-1">Bands</a></li>
            <li><a href="#tabs-2">My bands</a></li>
        </ul>
        <div id="tabs-1">
            <ul id="sortable1" class="bandList">

                <li id="6" class="band">
                    <div class="text">Band 1</div>
                    <div class="actions">
                        <a href="#" class="add">Add</a>
                        <a href="#" class="remove">Remove</a>
                    </div>
                </li>

            </ul>
        </div>
        <div id="tabs-2">
            <ul id="sortable2" class="bandList">

                <li id="9" class="band">
                    <div class="text">Band 2</div>
                    <div class="actions">
                        <a href="#" class="add">Add</a>
                        <a href="#" class="remove">Remove</a>
                    </div>
                </li>

            </ul>
        </div>
    </div>
</div>

CSS:

.band .actions a.add{
    background:url("../img/edit.png") no-repeat center center;
}

.band .actions a.remove{
    background:url("../img/delete.png") no-repeat center center;
}

JQuery:

// Listening for a click on an add button
$('.band a.add').live('click',function(){
    var cur_id = $(this).parent().parent().attr("id");

    var tmp = ($('#sortable2').has('#' + cur_id).length ? "Yes" : "No")
    alert(tmp);

    $('#sortable2').append($('#'+cur_id).clone());
});


// Listening for a click on a delete button (original)
$('.band a.remove').live('click',function(){
    var cur_id = $(this).parent().parent().attr("id");

    $('#sortable2 > li').remove('#' + cur_id);
});
  • 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-26T06:54:33+00:00Added an answer on May 26, 2026 at 6:54 am

    This line:

    ($('#sortable2').has('#' + cur_id).length ? "Yes" : "No");
    

    always returns "No". If you return length it will always return Yes. I couldnt get it to work with has, but it was returning correct result with children (I think). It will travel only one level though.

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

Sidebar

Related Questions

I have two tabs one called Sale-Items and the other All-Items and for each
i have two tabs tabfirst, tabsecond. whenever i select a tab(first or second) i
I have a tabhost with two tabs. Each tab has his own activity. My
I have a tab contol with two tabs. Each one containing listviews. When the
I'm developing an iPhone application that have a TabBarController with two tabs. Each tab
So, in my program i have a TabActivity which contains two tabs, one tab
I have two tabs. When I change a value in the first tab, another
I have tabbar - two tabs with navigation controller in each. On second card
I have two tabs in my home page and each tab has one jquery
I have Two Tabs Tab-1 and Tab-2 at bottom of the screen. Send button

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.