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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:59:48+00:00 2026-06-11T14:59:48+00:00

I have a number of list items each containing a hyperlink. What I want

  • 0

I have a number of list items each containing a hyperlink.
What I want to do is get the href from each link and apply it to the list item using the ‘on click’ using query. Meaning the whole li element will be clickable rather than just the hyperlink.

Current HTML:

<ul class="menusidecourse">
<li><a href="LINK1" >Item 1</a></li>
<li><a href="LINK2" >Item 2</a></li>
</ul>

What I want to end up with (either on the li click or on doc ready):

<ul class="menusidecourse">
<li onclick="location.href='LINK1';"><a href="LINK1" >Item 1</a></li>
<li onclick="location.href='LINK2';"><a href="LINK2" >Item 2</a></li>
</ul>

I’ve tried along these lines (but with no luck):

$('.menusidecourse li').click(function(){   
   var link = $('.menusidecourse li a', this).attr("href");
        $('.menusidecourse li', this).replaceWith('???');

    });

Thanks for looking!

note:
It must be done this way as the menu is generated dynamically by joomla.

  • 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-11T14:59:49+00:00Added an answer on June 11, 2026 at 2:59 pm

    Like this:

    // add a click handler to the li element
    $('.menusidecourse li').click(function(){
        // find the a element inside this li and get it's href   
        var link = $('a', this).attr("href");
        // navigate to the retrieved href
        window.location.href = link;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets' say we have list of items, each item has (unknown)number of attributes. Sorting
My goal is to have a list of items each item has an image
I have a list with items where each have number of properties (A, B,
i have a list 1 column and 100 rows each with a number the
I have a checkbox list generated using php depending upon number of coloumns in
I have a list like: list = [[1,2,3],[4,5,6],[7,8,9]] I want to append a number
I have a list of content items, each with a set width but different
I have an array of dictionary items containing a list of menus and their
I have a number of plural item classes which each have a collection of
Here's the problem: A user has a shopping basket containing items, where each item

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.