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

  • Home
  • SEARCH
  • 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 947845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:08:45+00:00 2026-05-15T23:08:45+00:00

Let’s say I have this line somewhere in my code: <ul id=mobileBtnsBot> <li> <a

  • 0

Let’s say I have this line somewhere in my code:

<ul id="mobileBtnsBot">
            <li>
                <a href="/m/alert/index.shtml"><span class="alertsBtn"></span><span class="btnText">Alerts & Advisories</span></a><div class="button_last"></div>
            </li>
            <li>
                <a href="/m/alert/index.shtml"><span class="schedBtn"></span><span class="btnText">Schedules</span></a><div class="button_last"></div>
            </li>
            <li>
                <a href="/m/alert/index.shtml"><span class="mapsBtn"></span><span class="btnText">Maps & Stations</span></a><div class="button_last"></div>
            </li>
            <li>
                <a href="/m/alert/index.shtml"><span class="trainBtn"></span><span class="btnText">TrainView</span></a><div class="button_last"></div>
            </li>
            <li>
                <a href="/m/alert/index.shtml"><span class="ntaBtn"></span><span class="btnText">Next To Arrive</span></a><div class="button_last"></div>
            </li>
            <li>
                <a href="/m/alert/index.shtml"><span class="faresBtn"></span><span class="btnText">Fares</span></a><div class="button_last"></div>
            </li>
            <li>
                <a href="/m/alert/index.shtml"><span class="mediaBtn"></span><span class="btnText">@ SEPTA</span></a><div class="button_last"></div>
            </li>
            <li>
                <a href="/m/alert/index.shtml"><span class="button_beg"></span><span class="btnText">Find my Location</span></a><div class="button_last"></div>
            </li>
        </ul>

I want to use JavaScript to find the <a> holding the text Find my location and hide it according to whichever user-agent your on.

I know you are not supposed to use user-agents as such but I can’t use any server-side languages.

If anyone knows how to accomplish this or has a better idea, please share.

EDIT: This page is being created from a web form in Alfresco CMS. If I give it an ID they all get the ID.

isBrowser.js

if (navigator.userAgent.indexOf('Gecko')!= -1
         || navigator.userAgent.indexOf('MSIE')!= -1 || navigator.userAgent.indexOf('Opera')!= -1 || navigator.userAgent.indexOf('Chrome')!= -1) {
    document.write('<link rel="stylesheet" href="/m/css/smartmobile.css" type="text/css" />');
}
else if (navigator.userAgent.indexOf('webkit')!= -1) {
    document.write('<link rel="stylesheet" href="/m/css/smartmobile.css" type="text/css" />');
}
else{
  alert("load mobile css");
  document.write('<link rel="stylesheet" href="/m/css/mobile.css" type="text/css" />');
    function hideListItem(text)
    {
        var ul = document.getElementById("mobileBtnsBot");
        alert("line1");
        for(var i = 0; i < ul.childNodes.length; i++)
        {
          alert("line2-loop");
            var li = ul.childNodes[i];
    alert("line3-loop");
            // Element node.
            if (li.nodeType == 1)
            {
              alert("line4-loop");
                // Find the text in all of the inner-html.
                if (li.innerHTML.indexOf(text) != -1)
                {
                  alert("line5-loop");
                    li.style.display = "none";
                    break;
                }
                alert("line6-loop");
            }
            alert("line7-loop");
        }
        alert("line8");
    }
     hideListItem("Find my Location");
}

mobile-script.js

window.onload = function () {
setTimeout(function(){window.scrollTo(0, 1);}, 100);
var linkElementLnk = document.getElementById("BackButtonlnk");
linkElementLnk.style.display = 'none';
insert();
}

function insert(){
var linkElement = document.getElementById("BackButton");
var linkElementLnk = document.getElementById("BackButtonlnk");
var loc_array = document.location.href.split('/');

if (loc_array[loc_array.length-3] == "maps"|| loc_array[loc_array.length-2] == "stations" || loc_array[loc_array.length-3] == "stations" )
{
  linkElementLnk.style.display = 'block';
  var newT = document.createTextNode("Stations & Maps");
}
else if (loc_array[loc_array.length-3] == "m")
{
  linkElementLnk.style.display = 'none';
}
else if (loc_array[loc_array.length-3] != "m")
{
    linkElementLnk.style.display = 'block';

     if (loc_array[loc_array.length-2] == "w" || loc_array[loc_array.length-2] == "s" || loc_array[loc_array.length-2] == "h" )
     {
        var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-2])));
     }

     else
     {
          if (loc_array[loc_array.length-1] == "index.html" || loc_array[loc_array.length-1] == "index.shtml" || loc_array[loc_array.length-1] == "")
          {
          var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-3])));
          }
          else
          {
          var newT = document.createTextNode(unescape(capWords(loc_array[loc_array.length-2])));
          }
     }
}
linkElement.appendChild(newT);
}
function capWords(str){ 
   var words = str.split(" "); 
   for (var i=0 ; i < words.length ; i++){ 
      var testwd = words[i]; 
      var firLet = testwd.substr(0,1); 
      var rest = testwd.substr(1, testwd.length -1) 
      words[i] = firLet.toUpperCase() + rest 
   }
   return words;
} 
  • 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-15T23:08:46+00:00Added an answer on May 15, 2026 at 11:08 pm

    EDIT:

    $("#mobileBtns > li:has(span:contains(TrainView))").hide();
    

    Change TrainView to whatever text you want to search for. This selects the li element under mobileBtns that has a span that contains the text TrainView. If you want a non-jquery solution let me know.

    function isBrowser(browserName)
    {
      var userAgent = navigator.userAgent;
    
      for(var i = 0; i < browserName.length; i++)
      {
          if(userAgent.indexOf(browserName[i]) != -1)
          {
              return true;
          }
      }
    
      return false;
    }
    
    if(isBrowser(["BlackBerry"]))
    {
       document.write('<link rel="stylesheet" href="/m/css/mobile.css" type="text/css" />');
    }
    else if(isBrowser(["iPhone", "Android", "Gecko", "MSIE", "Chrome", "Opera"]))
    {
      document.write('<link rel="stylesheet" href="/m/css/smartmobile.css" type="text/css" />');
    }
    else
    {
      document.write('<link rel="stylesheet" href="/m/css/mobile.css" type="text/css" />');
    }
    

    EDIT: You need to wrap the $(...) code after the document has loaded like this:

    $(document).ready(function ()
    {
        $("#mobileBtns > li:has(span:contains(TrainView))").hide();
    });
    

    EDIT 2: Here’s a javascript funciton that doesn’t use jQuery to find/hide the list item. Replace the $(document).read()... with this code:

    function hideListItem(text)
    {
        var ul = document.getElementById("mobileBtns");
    
        for(var i = 0; i < ul.childNodes.length; i++)
        {
            var li = ul.childNodes[i];
    
            // Element node.
            if (li.nodeType == 1)
            {
                // Find the text in all of the inner-html.
                if (li.innerHTML.indexOf(text) != -1)
                {
                    li.style.display = "none";
                    break;
                }
            }
        }
    
    }
    
    window.onload = function (e)
    {
        hideListItem("Schedules");
    };
    

    EDIT 3: Ok I think window.onload isn’t supported in your version of the browser. What you can do is move the JavaScript call to hideListItem() code to the end of the body tag:

    <html>
    <head>
    <!-- put your hideListItem function declaration here -->
    </head>
    <body>
    
    <!--...stuff here...-->
    
    <script type="text/javascript">
    hideListItem("Schedules");
    </script>
    
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have this code: <p dataname=description> Hello this is a description. <a
Let's say we have this code: <form action='' method='POST' enctype='multipart/form-data'> <input type='file' name='userFile'><br> <input
Let me explain best with an example. Say you have node class that can
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say I have a text file composed like this ##### typeofthread1 ##### typeofthread2
Let's say I have the following text: (example) <table> <tr> <td> <span>col1</span> </td> <td>col2</td>
Let's say I have the following classes : public class MyProductCode { private String
Let's say I have table with column 'URL' whrere I store urls like this

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.