我想在网站的多个但不是所有页面上隐藏一个 div。以下解决方案将其隐藏在一个页面上,但我如何添加两个或 3 个特定页面?
原始答案在这里:Hide div based on url
<script language="text/javascript">
$(function(){
if (window.location.pathname == "mywebsite/Videos.html") {
$('#navleft').hide();
} else {
$('#navleft').show();
}
});
</script>
最佳答案
只要给出一个或条件
$(function(){
if (window.location.pathname == "mywebsite/Videos.html"||window.location.pathname == "url2.html"||window.location.pathname == "url3.html") {
$('#navleft').hide();
} else {
$('#navleft').show();
}
});
关于jquery - 使用 jQuery 在某些页面上隐藏 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28034638/