Rectangle 27 0

javascript How to show div content in HTML when using BootStrap 3 navbar items?


<div id="home" style="display: none;">
    Test Data
</div>
<li><a href="#mywork" onclick="show_div('home');">My Work</a></li>

It should be sending home to target the div tag with your test data:

It's a simple error to make, sometimes when you make errors like this, you can't see them because you think it's something much bigger and look in all the wrong places.

That is perfect, thank you very much :) It was just a silly mistake on my part that caused my problem.

Your anchor onclick event is sending the wrong id

Note
Rectangle 27 0

javascript How to show div content in HTML when using BootStrap 3 navbar items?


<a id="sh" style="cursor:pointer">Show Home</a>
<div id="home" style="display: none;">Test Data</div>

<script type="text\javascript">
$(document).ready(function () {
    $("#sh").click(function () {
        $("#home").toggle();
    });
});
</script>

jQuery isn't tagged in the question, also the question isn't how to toggle elements. The question is "am I doing something wrong or can someone point me in the right direction" so correcting the existing source code would be the correct answer.

since the function would be used for multiple elements, you might want to think of using a class. Just a tip for next time or for your own use. Here's a quick example jsfiddle.net/485fzt0j Its better than having to add the .click() for each element.

Note