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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:12:43+00:00 2026-06-13T03:12:43+00:00

I want to append to an unordered list based on what the URL is.

  • 0

I want to append to an unordered list based on what the URL is. So if I am at mysite.com/es/instructions it appends “seleccionar” to the top of the unordered list and if I am at mysite.com/instructions it append “Select” to the top of the unordered list.

Here is what I started with and works fine:

$("ul.gallery").prepend('<li class="gallery-item"><a href="#">Select</a></li>'); 

Here is where I try to append based on the url:

$(function(){
var url = location.pathname;
if(url.indexOf('es') > -1){
    $("ul.gallery").prepend('<li class="gallery-item"><a href="#">Selecctioner</a></li>');
 } 
 else if (url.indexOf('') > -1) { 
   $("ul.gallery").prepend('<li class="gallery-item"><a href="#">Select</a></li>'); 
 }  
});

Any thoughts on why this isn’t working. I even put in an alert instead of the prepend statement to see if it worked and it did.

Here is the HTML:

<ul id="gallery-1" class="gallery list columns_3 ">
 <li class="gallery-item"> <a href="/instructions_en.pdf" title="English" class="gallery-icon"> English </a></li>
 <li class="gallery-item"> <a href="/instructions_en.pdf" title="French" class="gallery-icon"> Spanish </a></li>
 <li class="gallery-item gallery-endcol"> <a href="/instructions_en.pdf" title="German" class="gallery-icon"> German </a></li>
</ul>

What is supposed to happen is that the jquery script adds “Select” or “Selecctioner” to the top of the list depending on what URL they are on.

  • 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-13T03:12:45+00:00Added an answer on June 13, 2026 at 3:12 am

    Ok, my original script is working, my problem was that I had script above it that was turning my list into a drop down box. I had to move that code to the end so it was being ran last. It works. Here is the code that changes it to a drop down that I needed to move to the end, FYI:

    $(document).ready(function(){
    
    var $listItems = $('.gallery li');
    var $select = $("<select id='new-menu'>");
    
    $.each($listItems, function(idx,obj){
      var $option = $("<option>"+ $(obj).text() +"</option>").val( $(obj).find('a').attr('href') );
      if ( $(obj).hasClass('active') ){
        $option.attr('selected', 'selected');
      }
      $select.append($option);
    })
    
    $('.gallery').after($select);
    $('.gallery').remove();
    
    // Go to page on select.
    
    $('#new-menu').change(function(){
      var selected = $(this).find('option:selected');
      //alert('Going to: '+ selected.val());
      window.location.href = selected.val();
    });
    
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an unordered list with elements and I want to append an item
I want to be able to append items to an unordered list (wibble) when
I want to append a record in a TClientDataSet based on another record (in
I have an empty unordered list in my design. Now I want to add
I have an unordered list of 50 items. I want to show only 10
I want to convert the below table to unordered list: (This post not giving
If I want to append another image to this list. <img src=1.jpg alt=apple> If
i have a problem i take in input a list, and i want append
Here's the story. I've got an unordered list inside a div on my page.
I'm appending some items dynamically to an unordered list, but the jQuery .append() function

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.