Solved

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

Posted on 2014-09-16
2
1,087 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 500 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

622 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