Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jquery - Change <ul> content on specific <li> click

Posted on 2014-09-16
2
Medium Priority
?
1,150 Views
Last Modified: 2014-09-16
Hi,

See attached HTML. I want to change the content (<li> list) of a <ul> when specific list items are clicked.

I found the attached Jquery on the web; it doesn't work, you can try it at http://rkassoc.org/Davis/menu/menu_test.htm. Click the top list item (Irrigation).

How can I make this work, Obviously, the replacement list is just a test, real content is more elaborate.

Thanks,

Rkorts
menu-test.htm
0
Comment
Question by:Richard Korts
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 58

Accepted Solution

by:
Gary earned 2000 total points
ID: 40326590
As you have the function before the code actually exists it won't work as it doesn't exist in the DOM yet, you need to either move the jquery to the end of the page or wrap it in a doc ready function e.g.
$(function () {
    $('#irr').click(function () {
        $('#menu').html('<li>Context x</li><li>Context y</li><li>Context z</li>');
    });
})

Open in new window

0
 

Author Closing Comment

by:Richard Korts
ID: 40326722
Perfect!

Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question