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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:30:22+00:00 2026-05-18T09:30:22+00:00

I’m currently work on a site where definitions switch out on the homepage when

  • 0

I’m currently work on a site where definitions switch out on the homepage when users click on a word from a definition list. So far, I’m having issues figuring out the best approach. The code below is where I’m at now. While it doesn’t work, you can see the structure and what I’m trying to accomplish. Here’s the URL of the test site:
http://redone.org/_dev/ski/index.html

    <!-- Sub Nav -->
    <div id="menu-sub-menu" class="grid_3">
        <ul>
            <li id="d0" class="current_page_item"><a href="#">Sub Menu 1</a></li>
            <li id="d1" ><a href="#">Sub Menu 2</a></li>
            <li id="d2"><a href="#">Sub Menu 3</a></li>
            <li id="d3"><a href="#">Sub Menu 4</a></li>
            <li id="d4"><a href="#">Sub Menu 5</a></li>
            <li id="d5"><a href="#">Sub Menu 6</a></li>
        </ul>
        <script type="text/javascript">
        var definitions = ["definition 0 - Vivamus rutrum nunc non neque consectetur quis placerat neque lobortis. Nam vestibulum, arcu sodales feugiat consectetur, nisl orci.",
                           "definition 1 - Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor.",
                           "definition 2 - Nullam in dui mauris. Vivamus hendrerit arcu sed erat molestie vehicula. Sed auctor neque eu tellus rhoncus ut eleifend nibh porttitor. Ut in nulla enim.",
                           "definition 3 - Suspendisse dictum feugiat nisl ut dapibus. Etiam at risus et justo dignissim congue. Donec congue lacinia dui.",
                           "definition 4 - Ut in nulla enim. Phasellus molestie magna non est bibendum non venenatis nisl tempor.",
                           "definition 5 - Suspendisse dictum feugiat nisl ut dapibus. Mauris iaculis porttitor posuere. Praesent id."];
        var examples = ["Example 0 - Ut in nulla enim.",
                        "Example 1 - Suspendisse dictum feugiat nisl ut dapibus.",
                        "Example 2 - Mauris iaculis porttitor posuere.",
                        "Example 3 - Vivamus hendrerit arcu sed erat molestie vehicula. ",
                        "Example 4 - Sed auctor neque eu tellus.",
                        "Example 5 - Etiam at risus et justo dignissim congue."];
        for (i=0; i<6; i++){
            $("#d" + i).idx = i
            $("#d" + i).click(function(){
                $("#defined").html(definitions[this.idx]);
                $("#example").html(examples[this.idx]);
            });
        }
    </script>
    </div>
    <!-- Content -->
    <div id="definition" class="grid_13">
        <p id="defined" class="defined padthis">Mauris iaculis porttitor posuere. <a href="#">Praesent id metus massa</a>, ut blandit odio. Proin quis tortor orci. Etiam at risus et justo dignissim congue. Donec congue lacinia dui, a porttitor lectus condimentum laoreet. Nunc eu ullamcorper orci. Quisque eget odio ac lectus vestibulum faucibus eget in metus. In pellentesque faucibus vestibulum. Nulla at nulla justo, eget luctus tortor. Nulla facilisi. Duis aliquet egestas purus in blandit. </p>
        <p id="example">Proin quis tortor orci. Etiam at risus et <a href="#">justo dignissim congue.</a></p>
   </div>

Any help would be greatly appreciated.

  • 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-18T09:30:23+00:00Added an answer on May 18, 2026 at 9:30 am

    You can shorten that significantly using Attribute Starts With and .index():

    $("#menu-sub-menu > ul > li[id^=d]").click(function() {
        $("#defined").html(definitions[$(this).index()]);
        $("#example").html(examples[$(this).index()]);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from

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.