Change Display property on button click with Jquery

button, click, html, jquery

Solution

Using Jquery you can easily do the above task.Include Jquery Library, and use this code:

$("#btnStats").on("click",function(){

    $("#dvStats").css("display","block")
    $("#dvAlbums").css("display","block")

});

Problem

I'm trying to load a page where some divs are hidden, looks something like this: ``` <input type="button" id="btnStats" values="Stats"/> <div id="dvStats" style="display:none">Stats</div> <div id="dvAlbums" style="display:none">Albums</div> ``` Right now divs have just text, since I can't get them to work. I have a JS that assigns dvStats display to click event on btnStats. ``` $("#btnStats").click($("#dvStats").style.display="block"); ``` Also tried with some methods I saw while searching older questions about this. ``` $("#btnStats").click($("#dvStats").css(":display","block")); ``` I haven't been able to make this work. Maybe I missed something.

Original source