提问人:humbleCodes 提问时间:11/5/2023 最后编辑:humbleCodes 更新时间:11/5/2023 访问量:16
表元素的禁用属性的奇怪行为
Strange behavior of disabled property for table element
问:
因此,这是网站上提供的 .aspx 页面之一中的小型包装 HTML 元素。
<table id="ucDemographics_tdDemographic" style="width: 100%; height: 100%" cellspacing="0" cellpadding="3">
<tbody>
<!-- inner html code removed for readability purspose -->
</tbody>
</table>
其中一个 js 函数正在尝试通过 id 访问此元素并执行一些逻辑:
function Validate() {
// dropdown for physican name
var physicVal = document.getElementById('ucDemographics_uxddlPhysicianName').value;
// Empty physicianName validation
if (physicVal == "-1") {
window.alert('Validation(s) failed');
physicVal.focus();
return false;
}
// Empty nurseName validation
var tablebyID = document.getElementById('ucDemographics_tdDemographic');
if (tablebyID.disabled == false) {
// dropdown for nurse name
var nurseVal = $("#ucDemographics_uxGENurse").val() ;
if ( nurseVal == "-1") {
window.alert('Validation(s) failed');
nurseVal.focus();
return false;
}
}
return true;
}
我的问题是上面的 Validate 函数中的代码段如何能够访问 disabled 属性,因为它正在选择一个表标签,并且据我所知,它们不支持 disabled 属性。
var tablebyID = document.getElementById('ucDemographics_tdDemographic');
if (tablebyID.disabled == false) { }
这是我的 chrome 调试器的快照:
编辑01:当 onClick() 事件在提交按钮上触发时,将调用 Validate 函数。
答: 暂无答案
评论
Both dropdown elements values are set to -1. and click save button
Then alert message pops up as no physician name is not selected
So, we select a physician from the dropdown and again click on Save button
disabled