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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:32:36+00:00 2026-06-10T06:32:36+00:00

I am using http://www.bulgaria-web-developers.com/projects/javascript/selectbox/ to change a select box. Here is a example: http://jsfiddle.net/ukkpower/bczrc/1/

  • 0

I am using http://www.bulgaria-web-developers.com/projects/javascript/selectbox/ to change a select box.

Here is a example: http://jsfiddle.net/ukkpower/bczrc/1/

I have a button when clicked gets the text inside an ‘a’ tag below it. I have two types of these ‘a’. One that is part of the code on page load and the other that get dynamicly created with the select box plugin.

I can get the text from the ‘a’ tags that are part of the page but the dynamic ones I get empty string. I can see the text on the screen and the text is there as it should be when I inpect with firebug.

Why would $(this).next(".menuItem").text() not work with the dynamic one? I should see: 14′ – €14.14

 //button to get text
<a href="javascript:void(0)" class="addToCart cart"></a>

<div id="sbHolder_51608882" class="sbHolder" tabindex="1">
    <a id="sbToggle_51608882" href="#" class="sbToggle"></a>
    <a id="sbSelector_51608882" href="#" class="sbSelector menuItem">14' - €14.14</a>
         <ul id="sbOptions_51608882" class="sbOptions" style="display: none;">
              <li><a href="#1" rel="1">6' - €6.66</a></li>
              <li><a href="#2" rel="2">12' - €12.12</a></li>
              <li><a href="#3" rel="3" class="sbFocus">14' - €14.14</a></li>
         </ul>
</div>

This works ok and is part of the page on load:

<a href="javascript:void(0)" class="addToCart cart"></a>
<span class="price menuItem">12' - €12.99</span>
  • 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-10T06:32:38+00:00Added an answer on June 10, 2026 at 6:32 am

    Your expectations are incorrect. .next() fetches the immediate next element (sibling). Look at your HTML and you see that the sibling of:

    <a href="javascript:void(0)" class="addToCart cart"></a>
    

    Is :

    <div id="sbHolder_51608882" class="sbHolder" tabindex="1">
    

    If you want to access the anchor with class .menuItem which is within the div you need to go inside the div and find it.

    $(this).next("div.sbHolder").find("a.menuItem").text();
    

    DEMO – Display value from .menuItem

    Edit
    To address the 2 different scenarios you have one could apply some logic. This particular logic will work if you always have one or the other scenario. Off course, if you have completely random unpredictable scenarios this would not work.

    $(".addToCart").on("click", function() {
        var $menuItem = $(this).next(".menuItem");
    
        if($menuItem[0] === undefined){
            $menuItem = $(this).next().find(".menuItem");
        }
        alert($menuItem.text());
    });​
    

    DEMO – Find immediate next with .menuItem or child with .menuItem of immediate next

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

Sidebar

Related Questions

I am using opencv 2.3.1a in ubuntu 11.o4. I installed opencv using: http://www.samontab.com/web/2011/06/installing-opencv-2-2-in-ubuntu-11-04/ Since
I am using http://www.phpletter.com/Our-Projects/AjaxFileUpload/ ajax file upload plugin. Is there any way of passing
I'm using http://urlrewriter.net/ to rewrite urls at my website. For example, I'm rewriting: http://www.example.com/schedule.aspx?state=ca
In my application i want to get the weather report I'm using http://www.google.com/ig/api?weather= for
I am using jqGrid ( http://www.trirand.com/blog/ ) to display some read-only data. The resizeable
I'm using this ( http://www.j-download.com/demo/demo-j-dcontact.html ) form on my website. It works great but
Hy! I am using easyfacebookandroidsdk( http://www.easyfacebookandroidsdk.com/guide.asp ) for posting a status in facebook. I
Using this tutorial: http://www.c-sharpcorner.com/uploadfile/UrmimalaPal/creating-a-windows-phone-7-application-consuming-data-using-a-wcf-service/ I have created sample/hello world application on the windows phone
I am using an XPTable (http://www.codeproject.com/Articles/11596/XPTable-NET-ListView-meets-Java-s-JTable) and try to add a comboBox column. The
is there any free SQL formatter tool? I am using http://www.sqlinform.com/ for small queries.

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.