<html>
<head>
<title>实例</title>
</head>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<body>
<button id="b1"> 页面1 </button>
<button id="b2"> 页面2 </button>
<button id="b3"> 页面3 </button>
<button id="b4"> 页面4 </button>
<br>
<br>
<br>
<br>
<div class="page" id="page1" style="width:100px;height:200px;border:1px solid red;float:left;margin:20px;display:none;">
这是第一个页面
</div>
<div class="page" id="page2" style="width:100px;height:200px;border:1px solid red;float:left;margin:20px;display:none;">
这是第2个页面
</div>
<div class="page" id="page3" style="width:100px;height:200px;border:1px solid red;float:left;margin:20px;display:none;">
这是第3个页面
</div>
<div class="page" id="page4" style="width:100px;height:200px;border:1px solid red;float:left;margin:20px;display:none;">
这是第4个页面
</div>
<div style="float:clear;">
</div>
<br><br><br><br>
<br><br><br><br>
<br><br><br><br>
<button id="btn"> 这个是公共 按钮 </button>
</body>
<script>
$("#b1").click(function(){
$(".page").hide();
//显示页面1;隐藏按钮
$("#page1").show();
$("#btn").hide();
});
$("#b2").click(function(){
$(".page").hide();
//显示页面1;隐藏按钮
$("#page2").show();
$("#btn").show();
});
$("#b3").click(function(){
$(".page").hide();
//显示页面1;隐藏按钮
$("#page3").show();
$("#btn").show();
});
$("#b4").click(function(){
$(".page").hide();
//显示页面1;隐藏按钮
$("#page4").show();
$("#btn").show();
});
</script>
</html>
4个页面为什么都写在同一个文件中分开写不好吗?
解决方法:页面一按钮隐藏了,打开页面二的时候重新赋值display,让按钮展示就可以了啊。
用的是iframe吗?
<iframe class="xxx" id="iframe1">
<iframe class="xxx" id="iframe2">
<iframe class="xxx" id="iframe3">
<iframe class="xxx" id="iframe4">
通过class获取元素,如果id是iframe1则隐藏按钮,其他
远程看看
用的是iframe吗?
<iframe class="xxx" id="iframe1">
<iframe class="xxx" id="iframe2">
<iframe class="xxx" id="iframe3">
<iframe class="xxx" id="iframe4">
通过class获取元素,如果id是iframe1则隐藏按钮,其他则显示
用js 操作 不行吗 。获取button 合集 循环改变 样式
用绝对定位position: absolute和z-index;在页面一中,将按钮至于页面一的下方,即z-index的数值小于页面一,这样按钮就被隐藏了
解决办法:
首先,你需要给这四个按钮分别需要命名id, 例如:
<input type="button" id="one" value="按钮一" />
<input type="button" id="two" value="按钮二" />
<input type="button" id="three" value="按钮三" />
<input type="button" id="four" value="按钮四" />
假设你的公共按钮是:
<input type="button" onclick="test()" value="公共" />
然后你的jsp代码中引入js来控制:
<script>
function test(){
document.getElementById("one").style.display="none";
}
</script>
就写一个js做判断嘛,看看四个页面有没有什么标识性属性,举个例子,你可以获取路由,四个页面的路由名应该不一样,就进入这个页面时判断一下如果路由包含第一个页面那个路由名说明进入了第一个页面,隐藏对应的按钮否则不隐藏。
直接根据页面显隐判断按钮对应的方法
可以试试jq里面的隐藏显示,show(),hide()
弄四个按钮,把四个按钮跟四个页面的显示隐藏建立联系