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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:30:52+00:00 2026-05-11T10:30:52+00:00

I have a problem in my code. I want to get the b tag

  • 0

I have a problem in my code. I want to get the b tag that has the style color silver using Javascript. I tried using the tagName === ‘B’ but it didn’t work. I figured that the B tags are not children of the rowData class.

  <tr class='rowData'>     <td style='padding: 0pt;'>                 <table><tr>                 <td>                     <b style='font-size: 15px; color: silver;'>Mugging</b>                     <br />Payout: <b style='color: green;'>$200 - $300</b>                     <br />Experience: +1                                    </td>                  <td style='text-align: right;'>                                     </td>             </tr></table>         </td>         <td style='padding: 0pt;'>             <table><tr>                 <td style='width: 100px;'>                     <b style='color: gray;'>Required:</b>                      <br />Energy:&nbsp;1                                    </td>                 <td style=''>                                     </td>             </tr></table>         </td>          </td>   </tr> 

I removed some part of it..

Here’s some part of the Javascript code:

var jobs = {};  jobs.scan = function() {     var tagHolder = {};     var availJobs = {};     var jobContents = dom.get('app8743457343_content');     var rData = dom.getElementsByClass('rowData', jobContents, 'tr');     for(var i = 0; i < rData.length; i++) {         var rChildren = rData[i].childNodes;         for(var j=0; j<rChildren.length; j++) {             if(rChildren[j].tagName === 'B') {                 alert(rChildren[j]);             }         }     } }  jobs.scan(); 

When I started the script it didn’t alert, or responded. Maybe I need to use something to like nextSibling? Please help me figure this out.. I want the b with the style color silver. The Mugging text

  • 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. 2026-05-11T10:30:52+00:00Added an answer on May 11, 2026 at 10:30 am

    You could fight the good fight and try to get that monstrosity working across all browsers….

    Or, you could try jQuery! It’s fun and easy, and all the cool kids are doing it!

    var text = $('tr.rowData').find('b').filter(function() {     return $(this).css('color') == 'silver'; }).text(); alert(text); 

    Tada!

    EDIT: In all seriousness, if you want to do it in raw javascript, this works for me on IE and Firefox:

    var text; var bs = document.getElementsByTagName('b'); for(var x = 0; x < bs.length; x++) {     if(bs[x].style.color == 'silver') {         text = bs[x].innerHTML;         break;     } } alert(text); 

    It is just grabbing all the bold elements in the document and checking to see which one has a color of silver. This is not super efficient, obviously, and I am not sure of your use case. I do see in your code you are first grabbing a reference to a jobContents element. I am not sure where that is coming from as you didn’t post that part of the markup, but if the <b> will end up being inside this element, you can change this line:

    var bs = document.getElementsByTagName('b'); 

    To this:

    var bs = jobContents.getElementsByTagName('b'); 

    Which will then 1) speed it up, 2) make sure you get what you want.

    Good luck.

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

Sidebar

Related Questions

I have an intermittent problem with some code that writes to a Windows Event
I have problem in some JavaScript that I am writing where the Switch statement
I have a small problem. I am making a site that has Tags and
I have some JavaScript code and a button which already has an event/action assigned
I have problem with jCaret plugin in IE. jCaret downloads I want to get
I have a problem creating a for-loop using Javascript. It seems everyting is fine
I have a query where I need to get post + every tag that
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
Possible Duplicate: What's wrong with Delphi's “with” I am have a problem debugging code
I have a problem with the following code: for(i = 0;(i - 1)< n;i++)

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.