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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:55:25+00:00 2026-06-03T15:55:25+00:00

I am creating a small website that allows a user to browse some of

  • 0

I am creating a small website that allows a user to browse some of Shakespeare plays. I have it working that when a user clicks on a play, the name of the play is displayed in a header and the script of the play is displayed within a separate div.

This is working fine but I am now trying to organise the various plays into a drop down menu. I have split the plays into two categories (comedies and histories) and have grouped the plays accordingly.

The problem I now have is that once I click on a play via the drop down menu, the entire list of plays within that catergory (i.e. comedies) is displayed in the header instead of only the play I have selected. The play I selected however is still correctly shown in the div that displays the play (the ‘mainOutput’ div).

So basically what i need to know is how to I can set up that drop down menu so that only the title of the play I select shows in the header. Hopefully I have explained this correctly and any help would be appreciated! here is my code…

The jquery that initiates the play to be shown:

  $(document).ready(function(){   /* The code here can be modified to allow for any means of obtaining playName */
    $('li').click(function(event) {
  var playName = $(this).attr("id");
      $("header>span").text($(this).text());
      loadPlay(playName);
    });         

The drop down menu:

<div style="margin-left:50px;">
    <ul id="menu">
        <li><a href="#">Comedies</a>
            <ul id="help">
                <li>
                    <img class="corner_inset_left" alt="" src="corner_inset_left.png"/>
                    <li id="all_well.xml" class="comedy">All's Well That Ends Well</li>
                    <img class="corner_inset_right" alt="" src="corner_inset_right.png"/>
                </li>
                </ br>
                <li id="as_you.xml" class="comedy">As You Like It</li> </ br>
                <li id="com_err.xml" class="comedy">The Comedy of Errors</li> </ br>
              <li id="cymbelin.xml" class="comedy">Cymbeline</li> </ br>
              <li id="lll.xml" class="comedy">Love's Labours Lost</li> 
              <li id="m_for_m.xml" class="comedy">Measure for Measure</li> 
                          <li class="last">
                </li>
            </ul>
        </li>
        <li><a href="#">Histories</a>
            <ul id="help">
                <li>
                    <img class="corner_inset_left" alt="" src="corner_inset_left.png"/>
                     <li id="hen_iv_1.xml" class="history">Henry IV, Part I</li>                                                                        <img class="corner_inset_right" alt="" src="corner_inset_right.png"/>
                </li>
          <li id="hen_iv_2.xml" class="history">Henry IV, Part II</li> 
          <li id="hen_v.xml" class="history">Henry V</li> 
          <li id="hen_vi_1.xml" class="history">Henry VI, Part I</li> 
          <li id="rich_iii.xml" class="history">Richard III</li>
                <li class="last">
                </li>
            </ul>
        </li>
        </div>

Where the play data is displayed:

<header><span>Shakespeare's Plays<span></span></span></header>
  • 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-03T15:55:29+00:00Added an answer on June 3, 2026 at 3:55 pm

    This happens because you bind click event to all li items, including your dropdown list headings. You can change the selector to make it workable.

    $(document).ready(function() {
        $('#menu ul li').click(function(event) {
            var playName = $(this).attr("id");
            $("header > span").text($(this).text());
            loadPlay(playName);
        });
    });
    

    Of course, there are many other problems in your code.

    1. You should improve IDs of the elements (e.g. you have several elements with ID help, should be only one).
    2. List element ul should contain as first childs li elements only (you also have br elements, not correct).
    3. Pay attention, you have two span elements in header. Consider using only one if you wish to fill it with text (see JavaScript).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a task to create a website that'll allow creating small websites, mostely
I'm creating a small code plugin which allows you to do some things with
Suppose I'm creating a Wordpress website with user login and a small e-commerce. When
i'm creating a shopping website. i have a gridview that is bound to an
I have a portion of a website I am creating that is as follows:
I am planning on creating a small website for my personal book collection. To
I am creating small django application which holds some few questions (and answers for
I am creating a small modal form that is used in Winforms application. It
I am creating a small application that will be deployed on Window. The database
I'm creating a small app in ASP.NET MVC that generates ics (iCal) files based

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.