今天宝贝要实现点击更多来实现隐藏或开启DIV,想想就用JS来实现吧。
HTML:
1 <div onclick="divShowBatchName()">正常显示数据</div>
2
3 <div id="divBatchName" style="display:none">隐藏数据</div>
2
3 <div id="divBatchName" style="display:none">隐藏数据</div>
JS:
1 function divShowBatchName() {
2 //获取隐藏DIV ID
3 var showBatchName = document.getElementById("divBatchName");
4
5 //判断DIV是隐藏还是显示 如果隐藏 点击正常显示数据显示隐藏DIV 反之隐藏
6 if (showBatchName.style.display == 'block') {
7 showBatchName.style.display = 'none';
8 }
9 else {
10 showBatchName.style.display = 'block';
11 }
12 }
2 //获取隐藏DIV ID
3 var showBatchName = document.getElementById("divBatchName");
4
5 //判断DIV是隐藏还是显示 如果隐藏 点击正常显示数据显示隐藏DIV 反之隐藏
6 if (showBatchName.style.display == 'block') {
7 showBatchName.style.display = 'none';
8 }
9 else {
10 showBatchName.style.display = 'block';
11 }
12 }