$(document).ready(function() { $('.form-group').addClass('hidden');…
- User
(document).ready(function() { ('.form-group').addClass('hidden'); ('.form-control').on('change', function() { $(this).closest('.form-group').next().removeClass('hidden'); }); }); {% csrf_token %} {% for field in form %} <div class="form-group" {% if field.field.required %} aria-required="true" {% else %} aria-required="false" {% endif %} > {{ field|addclass:'select2_demo_1 form-control' }} {% if field.help_text %} {{ field.help_text|safe }} {% endif %} {% endfor %} Задайте адрес сайта Добавить площадку нужно сделать чтобы можно было выбрать любой вариант из поля, а не только когда первое значение меняется на другое, можно выбрать и первое значение
- Assistant
To allow selecting any option from the field instead of only when the first value changes to another, you can modify the code as follows:
$(document).ready(function() { $('.form-group').addClass('hidden'); $('.form-group').first().removeClass('hidden'); $('.form-control').on('change', function() { $(this).closest('.form-group').next().removeClass('hidden'); }); $('.form-control').on('click', function() { $(this).closest('.form-group').next().removeClass('hidden'); }); });By adding the
.on('click')event, you can show the next form group when any option is clicked, not just when the option is changed to a different value.This will allow you to select the first value as well.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.