JS/jQuery(隐藏div,在单击时显示div)
问题描述:
我有两个按钮.
我要显示两个divs.
I have two divs I want to show.
每个div都有不同的内容.
Each divs have different content.
我希望两个div只在页面上占用相同的空间.
I want both divs to only take up the same amount of space on the page.
我希望页面加载时如此显示div1,如果他们单击链接div2,则div1消失并且div2出现在其位置.
I want it so on page load, div1 is shown, and if they click link div2, div1 disappears and div2 appears in its place.
执行此操作的最佳方法是什么?以及如何?
What is the best way to go about doing this? and how?
答
除了所有最初的CSS和onload内容之外,您正在使用jquery, 我认为您正在寻找类似的东西
All the initial CSS and onload stuff aside and you're using jquery, I think you're looking for something like
$("#button2").click(function(){
$("#div1").hide();
$("#div2").show();
})