国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

select2的必填項(xiàng)為false時(shí),jquery無(wú)效
P粉775788723
P粉775788723 2023-09-03 10:06:25
0
1
930
<p>如何使用jQuery使select2的必填字段為false?我想使用jQuery使每個(gè)select2都要求= false并將其禁用。</p> <p>我嘗試了這個(gè)......但是$('#accodeformheader').find('input, select').attr('required', false);不起作用。 有沒有辦法使select2的“required”= false?</p> <pre class="brush:php;toolbar:false;">$(document).ready(function() { $('#idtask').change(function() { var taskVal = $(this).val(); console.log("當(dāng)前任務(wù)值", taskVal); if (taskVal === "Grass") { document.getElementById("idspeakerdetailsdiv").style.display = "block"; } else { document.getElementById("idspeakerdetailsdiv").style.display = "none"; } }) $('.lexemeview').click(function() { $('#accodeformheader').find('input, select').attr('disabled', true); $('#accodeformheader').find('input, select').attr('required', false); document.getElementById("accodeformheader").style.display = "none"; buttonType = $(this).attr("id") activeform(buttonType) $('#formdisplay').find('input, select').attr('disabled', true); $('#editbutton').attr('hidden', false); var accode = $(this).attr("id"); console.log(accode) $.getJSON("{{url_for('karya_bp.getonespeakerdetails')}}", { asycaccesscode:String(accode) }, function(data) { console.log(data) metadata = data.speakerdetails.current.workerMetadata console.log (metadata) $('#accesscode').attr('value', accode)</pre> <pre class="brush:php;toolbar:false;"><div id="accodeformheader" style="display: block;"> <div class="form-group"> <label for="idaccesscodefor">Access Code For:</label><br> <select class="accesscodefor" id="idaccesscodefor" name="accesscodefor" style="width:55%" required></select><br> </div> <div class="form-group"> <標(biāo)簽=“idtask”>任務(wù):
<select class="task" id="idtask" name="task" style="width:55%" required></select><br>
<div id="uploadaccode" style="display: block;"></div>
<div class="form-group"> <標(biāo)簽類=“col-form-label”>名稱:
<div class="form-group"> <標(biāo)簽=“sagegroup”>年齡組: <br> <選擇 class="age" id="idage" name="sagegroup" style="width:55%" 必需>; </選擇><br>
<div class="form-group"> <br> <選擇 class="educationlvl" id="idelevel" name="educationalevel" style="width:55%" 必需> </選擇><br> <div class="form-group"> <label for="moe12">教育程度(最多 12 級(jí)):</label><br> <選擇 class="educationmediumupto12" id="idmediumpre" name="moe12" multiple="multiple" style="width:55%" 必需>; </選擇><br> ; <div class="form-group"> <label for="moea12">教育程度(12 歲之后):</label><br> <選擇 class="educationmediumafter12" id="idmediumpost" name="moea12" multiple="multiple" style="width:55%" 必需>; </選擇><br> <輸入類型=“提交”值=“提交”> <br><br> </表格> </div></pre></p>
1
0
0
P粉775788723
P粉775788723

全部回復(fù)(1)
P粉762730205

如果您不需要,可以簡(jiǎn)單地刪除“required”屬性

$('select').removeAttr('required');

如果您想重新設(shè)置,請(qǐng)按照以下步驟進(jìn)行:

$('select').prop('required', 'required');

如果您想根據(jù)id或類刪除特定的select2下拉菜單,請(qǐng)按照以下步驟進(jìn)行:

$('#your_id_name').removeAttr('required');

使用類名:

$('.your_class_name').removeAttr('required');

同樣,您可以根據(jù)id和類進(jìn)行設(shè)置,如下所示:

$('#your_id_name').prop('required', 'required');

使用類名:

$('.your_class_name').prop('required', 'required');

我希望我理解您的問(wèn)題并給出了正確的答案。

熱門專題
更多>
熱門文章
熱門教程
更多>
最新下載
更多>
網(wǎng)站特效
網(wǎng)站源碼
網(wǎng)站素材
前端模板