You can use any accordion plugins to achieve this.
If you want to go with a small piece of code, go with this:
$('#btn1').click(function(){
$('.collapse').hide();
$('#demo').show();
});
$('#btn2').click(function(){
$('.collapse').hide();
$('#demo1').show();
});
1st div
2nd div