-5

Please help me, i'm having a hard time with this one. I already search for this one on google and here in stackoverflow but I wasn't able to find the specific answer to this one. I hope you can help me. Thanks!

Here's my code:

    $(document).ready(function() {
      $(".link").click(function() {    
        $(".hide").hide();
        var dataType = $(this).attr('data-type');
        $("#" + dataType).show();
    });
});

The previous div is still showing. :( I want to hide it once clicked the link and scroll down to the specific div within the page. :(

  • 1
    Can you please share what you have tried, some information on what is not working, and where you are stuck? The current question is too obscure to get a decent answer here on stackoverflow. – JanR Jan 09 '17 at 04:18
  • If you just use javascript, you can follow the answer - http://stackoverflow.com/questions/6242976/javascript-hide-show-element – user3205761 Jan 09 '17 at 04:21

1 Answers1

0

Since you didn't specify what your exact expectation, this one would help i guess

$("div").hide();
          // Show chosen div, and hide all others
        $("a").click(function (e) 
        {
            //e.preventDefault();
            $("#" + $(this).attr("class")).show().siblings('div').hide();
        });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
    Click to make it visible:<br /><br />
<a href="#" class="one">One</a>
<a href="#" class="two">Two</a>
<a href="#" class="three">Three</a>
<a href="#" class="four">Four</a><br /><br />

    <div id="one">One</div>
    <div id="two">Two</div>
    <div id="three">Three</div>
    <div id="four">Four</div><br/><br/>




</body>
Keshan Nageswaran
  • 8,060
  • 3
  • 28
  • 45
  • Hi Thanks to this. :D what i want is i have a question div and then when you click that div it will show you the answer. and within that div there is a link that when u click it, it will direct you to the specific div within that page. :( – Dap Javilinar Jan 09 '17 at 05:25