3 回答
TA贡献1835条经验 获得超7个赞
您在此行的加载功能中隐藏文本框:
if (inputtype != "Checkbox with Other"){
$("#checkboxvalues").hide();
}
作为代码审查问题,您可能希望将所有逻辑放在一个函数中,以便只调用一次。
$(document).ready(function(){
function updateInputs() {
var inputtype = $( "#inputtype" ).val();
$("#checkboxvalues").toggle(inputtype === "Checkbox" || inputtype === "Checkbox with Other");
$("#radiovalues").toggle(inputtype === "Radio" || inputtype === "Radio with Other");
}
updateInputs();
$('#inputtype').on('change', updateInputs);
});
TA贡献2021条经验 获得超8个赞
这应该有效,
var inputtype = $( "#inputtype option:selected" ).val();
希望能帮助到你!
并尝试使用数组而不是比较每个单独的文本,(editedsitefield.fieldinputtype == "Text Box")即在数组中存储“文本框”之类的值,循环遍历它。
添加回答
举报
