我有一个带有隐藏输入字段的 Web 表单,如下所示:
<input id="requiredFields" name="requiredFields" type="hidden" value="firstname,lastname,email,phone">
我想,location
使用jQuery根据特定条件添加和删除“”,如下所示:
$('input[name="locationstatus"]:radio').on("change", function() {
if ($('input[name="locationstatus"]:radio:checked').val() == 'Yes') {
/* need syntax to append text ',location' to #requiredFields string */
}
else {
/* need syntax to remove text ',location' from #requiredFields string */
}
});
谢谢