【发布时间】:2009-06-05 19:31:23
【问题描述】:
我有一个关于选择 ID 的 jquery 问题。
基本上,我从传入控件 ID 和 LabelId 的 onClick 函数调用 javascript 函数。
如果我使用 document.getElementById,它会起作用,但是,如果我使用 jQuery 选择器,它就不起作用。
<script type="text/javascript">
jQuery.noConflict();
function ToggleProgressEnable(valueofRadio, controlId, labelId) {
//Comments: the following will work.
// var control = document.getElementById(controlId);
// var label = document.getElementById(labelId);
//The following is not working.
var control = jQuery("'#" + controlId + "'");
var label = jQuery("'#" + labelId + "'");
if (control != null && label!=null) {
//alert(control.Id);
//alert(control.disabled);
if (valueofRadio == "yes") {
control.disabled = false;
label.disabled = false;
}
else if (valueofRadio == "no") {
control.disabled = true;
control.value = "";
label.disabled = true;
}
//alert(control.disabled);
}
}
</script>
【问题讨论】:
标签: javascript jquery