DIV禁用或变灰 [英] DIV disabled or greyed out
问题描述
我有一个形式的网页。根据用户的选择在顶部
该页面,该页面将禁用形式的部分。我的计划是把
一个℃至每节; DIV>< / DIV>
。每一节都包含一些集合
的表单元素。
I have a webpage with a form. Depending on user selections at the top of
the page, the page will disable sections of the form. My plan is to put
each section between a <div></div>
. Each section contains some collection
of form elements.
因此,如果用户不选择一些条件,对相关的部分
形式被禁用。在一个典型的Windows类型的应用这些元素的
得到禁止和灰色。什么是在网页中做到这一点的最好方法是什么?
JavaScript可以确定何种形式元素是一个div部分,
禁用通过例如环这些元素?我知道我可以禁用
每一个元素,如果我知道它,但有没有办法找出所有的ID
对于一些的div元素节?
So if the user does not select some criteria, the related section of the form gets disabled. In a typical Windows type of application these elements get disabled and greyed out. What's the best way to do this in a webpage? Can Javascript determine what form elements are in a div section and disable these elements through a loop for example? I know I can disable each element if I know its it but is there a way to find out all the IDs of elements for some div section?
是否有可能在页面加载事件的基础上在c#标志变量变灰?
Is it possible to gray out in page load event based on flag variable in c#?
推荐答案
给你的div元素的ID,然后取它里面的所有的标签和残疾人属性适用于他们。
Give your div element an id and then take all tags inside it and apply the disabled attribute to them.
var elem = document.getElementById ( "div1").getElementsByTagName ( "*");
for ( var i=0; i < elem.length; i ++ )
{
elem[i].disabled = true;
}
要启用控件disabled属性设置为false。
To enable the controls set the disabled attribute to false.
这篇关于DIV禁用或变灰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!