5
I have a little doubt in my project that I am developing.
I need to make that determined <article> appears when a certain <li>.
Example
<li>'s
<li id="menu-CARD">USAR CARD</li>
<li id="menu-SLIP">USAR SLIP</li>
Example
<article>'s
<article id="CARD">CONTEÚDO CARD</article>
<article id="SLIP">CONTEÚDO SLIP</article>
I need two things.
- 1° When clicking on one of the
<li>, be added to class "Selected" à<li>clicked. (class="selected") - 2° When clicking on a
<li>, will be shown the<article>that is referred to that<li>that was clicked.
Example: by clicking on <li> "SLIP":
<li id="menu-SLIP">USAR SLIP</li>
Will be added a style="display:block" at the <article> id "SLIP":
<article id="SLIP">CONTEÚDO SLIP</article>
Thus remaining:
<article id="SLIP" style="display:block">CONTEÚDO SLIP</article>
Obsevation:
Its function will be similar to a tab.
When you click USE CARD, you will see the <article> id "CARD".
When you click USE SLIP, you will see the <article> id "SLIP".
That is, as long as one receives display:block, the other receives display:None.
Buddy, I tested your code. There are two problems, first, it gives the "display:None" in all the Articles of the page (is it possible to do somentes in Articles with a certain class? guy:
<article class="este-pode") ?. Second, it does not remove the class "Selected". The correct is while one li stays with "Selected" the other is without "Selected".– Alexandre Lopes
Buddy, I solved the part where I choose which
<articles>will receive thedisplay:none, I switched to$('.essesim').css('display','none');... Now just need to make that only 1<li>stay with theclass=selected.– Alexandre Lopes
I adjusted this question in the answer, take a look.
– lfarroco
It was perfect! Congratulations on your knowledge and for helping people with it! Thank you very much. I only have one additional question :3, it is possible to make that when the person clicks on the li, the screen descends to the beginning of the
<li>? Very bomm!– Alexandre Lopes
Like that smooth scroll that makes hers go down
<li>clicked.– Alexandre Lopes
The scroll can be implemented with this snippet here, I will include in the answer: http://stackoverflow.com/a/6677069/2467235
– lfarroco
PERFECT!!! You are a genius!
– Alexandre Lopes