Я смог получить выпадающие значения, чтобы измениться при выборе радиопроизводств, но изображение продукта не обновляется, как это должно. Изображение обновляется только при использовании фактического выпадающего списка. И вот мой код до сих пор: < /p>
$(".variant-option select").each(function() {
var select = $(this);
var selectName = select.attr("name");
// Create a container for the radio buttons
var radioContainer = $("");
select.find("option").each(function(i, e) {
var optionValue = $(this).val();
var optionText = $(this).text();
// Create a radio button for each option
$("")
.attr("value", optionValue)
.attr("id", selectName + "_" + i) // Add an ID for the label
.attr("checked", i == 0)
.click(function() {
// Update the select element's value
select.val(optionValue);
// Trigger the change event on the select element
select.trigger('change');
})
.appendTo(radioContainer);
// Create a label for the radio button
$("" + optionText + "")
.appendTo(radioContainer);
});
// Add the radio buttons after the select element
radioContainer.insertAfter(select);
});
Я смог получить выпадающие значения, чтобы измениться при выборе радиопроизводств, но изображение продукта не обновляется, как это должно. Изображение обновляется только при использовании фактического выпадающего списка. И вот мой код до сих пор: < /p> [code]
$(".variant-option select").each(function() { var select = $(this); var selectName = select.attr("name");
// Create a container for the radio buttons var radioContainer = $("");
select.find("option").each(function(i, e) { var optionValue = $(this).val(); var optionText = $(this).text();
// Create a radio button for each option $("") .attr("value", optionValue) .attr("id", selectName + "_" + i) // Add an ID for the label .attr("checked", i == 0) .click(function() { // Update the select element's value select.val(optionValue);
// Trigger the change event on the select element select.trigger('change'); }) .appendTo(radioContainer);
// Create a label for the radio button $("" + optionText + "") .appendTo(radioContainer); });
// Add the radio buttons after the select element radioContainer.insertAfter(select); });