Hide particular div onload and then show div after click
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have two divs div1 and div2 . I want div2 to be automatically hidden but when i click on preview div then div2 to be made visible and div1 to hide. This is the code i tried but no luck :( This is preview Div1. This is preview Div1. This is preview Div2 to show after div 1 hides. PREVIEW 回答1: Make sure to watch your selectors. You appear to have forgotten the # for div2 . Additionally, you can toggle the visibility of many elements at once with .toggle() : // Short-form of `document.ready` $(function(){ $("#div2").hide(); $("#preview").on(