0

Hi would you please help how can i extract "Men" text in this case?

<div class="comwebstore-LeftNavBrowse-2">
    <ul class="linkList browseLadder">
       <li>
           <a href="example.com"> Men </a>
       </li>
       <ul class="linkList browseLadder">
         <li>
            <a href="example.com"> Full Logo T-Shirt </a>
         </li>
         <li>
            <a href="example.com"> Short Logo T-Shirt </a>
         </li>
         <li>
            <a href="example.com"> Grey Hoodie 1 Full Logo </a>
         </li>
         <li>
           <a href="example.com"> Grey Hoodie 2 Short Logo </a>
         </li>
         <li>
            <a href="example.com"> Women </a>
         </li>
         <li>
            <a href="example.com"> Accessories </a>
         </li>
       </ul>
     </ul>
  </div>
</div>

I have tried

jQuery('#mainContentWrapper #leftColumn #A #A-1 .com-amazon-webstore-LeftNavBrowse-2 > :first-child a').text();

but without succeed. Thanks

1
  • By what criteria? Will it always be the first item? Commented Jul 30, 2012 at 11:53

2 Answers 2

1

From your html:

alert($('.linkList > li:first a').text());
Sign up to request clarification or add additional context in comments.

2 Comments

that's shows both Men and "Full Logo T-shirt". it should only shows "Men". THanks
@thelinhbui try: $('.comwebstore-LeftNavBrowse-2 ul:first > li:first a').text()
0

Check your selector...<div class="comwebstore-LeftNavBrowse-2"> You have comwebstore-LeftNavBrowse-2 class and you're using .com-amazon-webstore-LeftNavBrowse-2

Please dont use such a long selectors. This will reduce your selectors performance and it looks ugly. Just check what Alex Ball has suggested.

jQuery('#mainContentWrapper #leftColumn #A #A-1 .comwebstore-LeftNavBrowse-2 > :first-child a').text();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.