SELECT
功能仅在第一时间有效,而在其他时间无效。
表单转发器添加而不选择div隐藏。
使用表单转发器不选择显示隐藏div
我希望你能告诉你是否有帮助
如何在Repeater中隐藏一个div
我希望它在每次迭代中都能正常工作,因为它很重要
问题第一次工作
function markCheckBox(ctrl) {
$('input:radio.group-name').prop("checked", false);
$("[name='" + ctrl + "']").prop("checked", true);
}
$('#result').on('change', function() {
$('#fail').css('display', 'none');
if ($(this).val() === 'Fail') {
$('#fail').css('display', 'block');
}
if ($(this).val() === 'Pass') {
$('#pass').css('display', 'block');
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="kt-portlet__body">
<div class="kt-form__section kt-form__section--first">
<div id="kt_repeater_1">
<div class="form-group form-group-last row" id="kt_repeater_1">
<label class="col-lg-2 col-form-label">Contacts:</label>
<div data-repeater-list="soru" class="col-lg-10">
<div data-repeater-item class="form-group row align-items-center">
<div class="col-md-3">
<div class="kt-form__group--inline">
<div class="kt-form__label">
<label>Name:</label>
</div>
<div class="kt-form__control">
<input id="fail" style="display:none" type="text" name="soru" class="form-control" placeholder="Soru">
</div>
<div class="kt-form__control">
<input id="pass" style="display:none" type="file" class="form-control" name="resim">
</div>
</div>
<div class="d-md-none kt-margin-b-10"></div>
</div>
<div class="col-md-3">
<div class="kt-form__group--inline">
<div class="kt-form__label">
<label class="kt-label m-label--single">Number:</label>
</div>
<div class="kt-form__control">
<select id="result" name="result" class="form-control kt-selectpicker" title="Success" data-style="btn-success">
<option>Mustard</option>
<option value="Pass">Ketchup</option>
<option value="Fail">Relish</option>
</select>
</div>
</div>
<div class="d-md-none kt-margin-b-10"></div>
</div>
<div class="col-md-2">
<div class="kt-form__group--inline">
<div class="kt-form__label">
<label class="kt-label m-label--single">Number:</label>
</div>
<div class="kt-form__control">
<label class="kt-radio">
Test
<input type="radio" id="CtrlName" name="dogru_cevap" class="group-name" value="dasdas" onclick="markCheckBox(this.attributes['name'].value);" />
<span></span>
</label>
</div>
</div>
<div class="d-md-none kt-margin-b-10"></div>
</div>
<div class="col-md-2">
<a href="javascript:;" data-repeater-delete="" class="btn-sm btn btn-label-danger btn-bold">
<i class="la la-trash-o"></i> Sil
</a>
</div>
</div>
</div>
</div>
<div class="form-group form-group-last row">
<label class="col-lg-2 col-form-label"></label>
<div class="col-lg-4">
<a href="javascript:;" id="add" data-repeater-create="" class="btn btn-bold btn-sm btn-label-brand">
<i class="la la-plus"></i> Add
</a>
</div>
</div>
</div>
<div class="kt-separator kt-separator--border-dashed kt-separator--space-lg"></div>
</div>
</div>
<div class="kt-portlet__foot">
<div class="kt-form__actions">
<div class="row">
<div class="col-lg-2"></div>
<div class="col-lg-2">
<button type="submit" class="btn btn-success">Submit</button>
</div>
</div>
</div>
</div>