可以通过以下方法给 input 框添加 required 属性:

方法一:

$('#inputId').prop('required', true);

方法二:

$('#inputId').attr('required', 'required');

其中,#inputId 是你要添加 required 属性的 input 框的 id。你可以根据实际情况修改 id 的值。

jQuery 为 Input 框添加 Required 属性

原文地址: https://www.cveoy.top/t/topic/qxY0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录