javascript 隐藏/显示指定的区域附HTML元素【legend】用法
作者:bea
javascript code: 代码 代码如下: function expandOther(el, el2) { whichEl = document.getElementById(el) button = document.getElementById(el2) if (whichEl.style.display == 'none') { whichEl.style.display = ''; button.value = "隱藏"; } else {
javascript code:
代码
代码如下:
function expandOther(el, el2) {
whichEl = document.getElementById(el)
button = document.getElementById(el2)
if (whichEl.style.display == 'none') {
whichEl.style.display = '';
button.value = "隱藏";
}
else {
whichEl.style.display = 'none';
button.value = "顯示";
}
expandOther(e1,el2),
e1参数可以指定需要操作的事件对象,比如一个ID为inputshowData的Input按钮,
el2参数可以指定需要隐藏的一个区域,可以是TABLE,div等。
<input name="inputshowData" id="inputshowData" value="隱藏" type="button" onclick="expandOther('datadiv','inputshowData')" />
id为datadiv 数据显示层区域
id为inputshowData 操作按钮
HTML示例CODE:
代码如下:
<fieldset>
<legend>
<input name="inputshowData" id="inputshowData" value="隱藏" type="button" onclick="expandOther('datadiv','inputshowData')" /></legend>
<div id="datadiv" style="width: 400PX; height: 100px; overflow: auto;">
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</div>
</fieldset>
是不是发现很简单呢?
个人觉得。
不过这个层有滚动条,主要是基于style属性overflow:auto;和有指定的宽度和高度。
如果不直接指定宽度,那以浏览器的宽度为标准显示滚动条,
如果没有指定高度,则不会显示向下的滚动条,似乎是这样。俺对美工不咋的。今天权当记录在这里,以后可以回头看看当时自己是怎么个理解和写的代码。
有用 | 无用
代码
代码如下:
function expandOther(el, el2) {
whichEl = document.getElementById(el)
button = document.getElementById(el2)
if (whichEl.style.display == 'none') {
whichEl.style.display = '';
button.value = "隱藏";
}
else {
whichEl.style.display = 'none';
button.value = "顯示";
}
expandOther(e1,el2),
e1参数可以指定需要操作的事件对象,比如一个ID为inputshowData的Input按钮,
el2参数可以指定需要隐藏的一个区域,可以是TABLE,div等。
<input name="inputshowData" id="inputshowData" value="隱藏" type="button" onclick="expandOther('datadiv','inputshowData')" />
id为datadiv 数据显示层区域
id为inputshowData 操作按钮
HTML示例CODE:
代码如下:
<fieldset>
<legend>
<input name="inputshowData" id="inputshowData" value="隱藏" type="button" onclick="expandOther('datadiv','inputshowData')" /></legend>
<div id="datadiv" style="width: 400PX; height: 100px; overflow: auto;">
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
</div>
</fieldset>
是不是发现很简单呢?
个人觉得。
不过这个层有滚动条,主要是基于style属性overflow:auto;和有指定的宽度和高度。
如果不直接指定宽度,那以浏览器的宽度为标准显示滚动条,
如果没有指定高度,则不会显示向下的滚动条,似乎是这样。俺对美工不咋的。今天权当记录在这里,以后可以回头看看当时自己是怎么个理解和写的代码。
有用 | 无用
猜你喜欢
您可能感兴趣的文章:
- Jquery实现无刷新DropDownList联动实现代码
- JavaScript this调用规则说明
- javascript 放大镜 v1.0 基于Yui2 实现的放大镜效果
- JavaScript中的闭包原理分析
- ExtJS GridPanel 根据条件改变字体颜色
- JavaScript通过attachEvent和detachEvent方法处理带参数的函数
- JavaScript 滚轮事件使用说明
- javascript下4个跨浏览器必备的函数
- Zero Clipboard js+swf实现的复制功能使用方法
- GWT中复制到剪贴板 js+flash实现复制 兼容性比较好
- javascript实现面向对象类的功能书写技巧
- js实现的真正的iframe高度自适应(兼容IE,FF,Opera)
- 全选并改变TR颜色的javascript实现代码
- jQuery html() in Firefox (uses .innerHTML) ignores DOM changes
- Jquery Validation插件防止重复提交表单的解决方法
- javascript下判断一个元素是否存在的代码
- ExtJs扩展之GroupPropertyGrid代码
- js 获取服务器控件值的代码
- jquery checkbox全选、取消全选实现代码