When you click on a link, close all open Ivs and open a specific one?

Asked

Viewed 307 times

-3

I’m developing a site that will be just a page and will not have scrolling, I need when I click a < a> close the open div and open the one I passed in href="" from < a>.

  • Using some front end framwork like Angularjs, Knockout or Ember?

  • 1

    Cool. But what you tried so far?

  • 2

    duplicate of several questions... this one maybe: http://answall.com/questions/2365/como-esconder-um-sub-menu-vis%C3%Advel-ao-clique-em-outro-menu-em-js/2366#2366

  • 1

    Does that question not help you? http://answall.com/questions/25611/criar-um-menu-accordion-apenas-com-css

  • No man, it can’t be with Focus, it’ll be touch.

  • Eduardo, without putting your HTML this question is very general and will be closed as duplicate of what is most similar.

Show 1 more comment

1 answer

-1

does something like this... when you click on the div, give an Hide to it ( display:None ) and the others you give a show ( display: block )

$( "a" ).click(function({
   this.hide(); // ou this.css( 'display', 'none' );
   $( "#outrasDIVs" ).show(); // ou $( "#outrasDIVs" ).css( 'display', block );
}));
  • I have to vote -1 because this.hide(); will give error, and because "#outrasDIVs" doesn’t make much sense since ID’s have to be unique: and because it should be the other way around. Hide all but one.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.