On click of the button A, call a JavaScript function which will make the particular div visible and which will replace button A with button B.
when button B is visible, that button will call a JavaScript function which will make the div hidden and which will replace button B with button A.