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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:15:02+00:00 2026-05-14T07:15:02+00:00

given the html: <div class=ships> <div class=ship header> </div> <div class=ship> <div class=image> <img

  • 0

given the html:

<div class="ships">
  <div class="ship header">
  </div>
  <div class="ship">
    <div class="image">
      <img alt="Hermes_class" src="..." />
    </div>
    <div class="number">x10</div>
  </div>
 ... //other ships

I want only the number text of the ship matching img alt=”Hermes_class”.

Here’s where I start:

var finalShipListDom = $jq('div.ship:not(.header)', finalCombatantShips);
             if(finalShipListDom.length<=0)
                 console.log("fsld="+finalShipListDom.length);

i’ve tried all these to get the ship dom so I could go down from there to get the number.

$jq('div.ship',finalShipListDom).filter('div.image img[alt="' +shipClass + '"]');

and

 var finalShipDomFilter= function(index){
               return jQuery('div.image',this).length>=1;
             }

and

     var finalShipDomFilter= function(index){
               return jQuery('div div.image',this).length>=1;
             }

all are returning 0 length.

There’s a debug bin/live example available at http://jsbin.com/alebi3/9/edit

  • 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-14T07:15:03+00:00Added an answer on May 14, 2026 at 7:15 am

    It sounds like you want jQuery.has(). Something like this should get you the div that contains the div <div class="number">x10</div>:

    $jq('div.ship:not(.header)', finalCombatantShips)
        .has('div.number > img[alt=' + shipClass + ']');
    

    N.B. you do not need to insert quotes into the attribute value in the selector.

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

Sidebar

Related Questions

Given this html: <div class=nation> <a href=library.php?type=nation&amp;id=America> <div class=nation-image> <img src=nations/America.png alt=snip /> </div>
Given the following HTML snippet: <div class=image> <div class=placeholder> <a class=load iframe href=https://contestapp.com/images/4><img src=/uploads/image/image_file/4/thumb_he_sport_nutrition_for_active_kids_photo.jpg?1307271623
Given this HTML: <div class=OpenIDSelector>some text</div> Why does this JQuery selector match it on
Given this HTML: <div id=foo> <input type=button class=foo abtn_1> <input type=button class=joe bbtn_2> <input
Given this HTML: <div id=foo> <input type=button class=foo abtn_1> <input type=button class=joe bbtn_2> <input
Given an HTML like following: ...more html above... <div class=any_name> <p>Element A goes here</p>
Given the following HTML: <div class=foo>howdy howdy howdy how</div> <div class=bar>Hello</div>​ and the following
In my html i have got div with given class. After clicking a button
Given the following html: <div id='foo'> <div class='prodbar'> <div class='title'>Group 1</div> <div class='product'>Product #1</div>
Given the following html... <div id=group> <ul> <li><div class=category>one</div></li> <li><div class=category>one</div></li> <li><div class=category>onetwo</div></li> <li><div

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.