<p><textarea cols="50" rows="15" name="code" class="javascript:nogutter"> function selectChanged(target, containerId) {
var value = target.options[target.selectedIndex].value;
var cont = $("#" + containerId);
switch (value) {
default:
$("input", cont).each(function () {
$(this).attr("disabled", "");
$(this).css({ background: "white" });
});
break;
case "0":
case "none":
case "hidden":
$("input", cont).each(function () {
$(this).val('');
$(this).css({ background: '#F0F0F0' });
$(this).attr("disabled", "disabled");
});
break;
}
}</textarea></p>
<p>遍历容器中所有input 并设置其状态值:可用与不可用</p>
var value = target.options[target.selectedIndex].value;
var cont = $("#" + containerId);
switch (value) {
default:
$("input", cont).each(function () {
$(this).attr("disabled", "");
$(this).css({ background: "white" });
});
break;
case "0":
case "none":
case "hidden":
$("input", cont).each(function () {
$(this).val('');
$(this).css({ background: '#F0F0F0' });
$(this).attr("disabled", "disabled");
});
break;
}
}</textarea></p>
<p>遍历容器中所有input 并设置其状态值:可用与不可用</p>
本文介绍了一个使用JavaScript实现的功能,该功能可以根据不同的选择项来改变输入框的状态,包括禁用和启用状态,以及背景颜色的变化。
1万+

被折叠的 条评论
为什么被折叠?



