[英]JavaScript .click() not changing CSS "display" property
I'm trying to make a navigation bar which on click to make visible a div that has been previously hidden with display: none
.我正在尝试制作一个导航栏,单击该导航栏可使之前用
display: none
隐藏的 div 可见。 Below is what I have till now:以下是我到目前为止所拥有的:
Navigation bar:导航栏:
$(document).ready(function() { $('#home').click(function() { $('.site-content').html($('#home_wrap')); }); $('#skills').click(function() { $('.site-content').html($('#skills_wrap')); });
#home_wrap, #skills_wrap { display: none; }.site-content { max-width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
<div class="nav__content"> <ul class="nav__list"> <li class="nav__list-item" id="home" href="#">Home</li> <li class="nav__list-item" id="skills" href="#">Skills</li> </ul> </div>
As this is an old project, I think the navigation used to work but now it's not.由于这是一个旧项目,我认为导航过去可以工作,但现在不行了。
Try to use: $('#home_wrap').show()尝试使用:$('#home_wrap').show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.