How to show a specific div with its own id in jQuery when I click a link?

I have a div like this:

<article id="#pippo">blablabla</article>

that I have hided with jQuery


now I'd like to have a link menu that show a specific article id when it's clicked for example.

If I click on link:

<a href="#pippo"> LINK PIPPO </a>

I'd like that the article named #pippo is shown

if I click on link that point to #pluto, an article with id #pluto have to be shown...

how can I do this in jQuery?


If you want this to work for every <a> tag on your page then you can do the following

$('a').click(function (e) {
  var id = $(this).attr('href');

  // Don't follow the link

More likely though you want this to work on a subset of <a> on the page. If so you can distinguish them by putting a class in the link and changing your selector as appropriate


<a href="#pippo" class="fakeLink"> LINK PIPPO </a>


$('a.fakeLink').click(function (e) {
  var id = $(this).attr('href');

  // Don't follow the link

Need Your Help

What is the performance (Big-O) for removeAll() of a treeset?

big-o treeset removeall

I'm taking a Java data structures course atm. One of my assignment asks me to choose a data structure of my choice and write a spell checker program. I am in the process of checking the performance...

Problem with skipping empty cells while importing data from .xlsx file in c# application

c# parsing spreadsheet xlsx

I have a problem with reading .xlsx files in mvc2.0 application, using c#. Problem occurs when reading empty cell from .xlsx file. My code simply skips this cell and reads the next one.