StartGames,
Сообщение от Malleys
|
Если без привлечения лишних сущностей, то можно, например, так...
|
https://javascript.ru/forum/xhtml-ht...tml#post517046
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8">
<style type="text/css">
.radio-input.active {color:red !important}
</style>
<script>
document.addEventListener("change", event => {
const container = event.target.closest("[name='shipping_method']");
if(container) {
const root = container.closest("#shipping_method_list");
if(!root._lastContainer) root._lastContainer = root.querySelector("div.radio-input");
root._lastContainer.classList.remove("active");
const div = container.closest("div.radio-input");
div.classList.add("active");
root._lastContainer = div;
}
});
</script>
</head>
<body>
<div id="shipping_method_list">
<strong class="title nn">Доставка</strong>
<div class="radio-input radio active" id="su.flat.flat">
<label for="flat.flat"><input type="radio" name="shipping_method" value="flat.flat" id=
"flat.flat" checked="checked" data-refresh="5" class="styled"> <span class=
"text">Доставка</span><span class="price">80 руб</span></label>
</div><strong class="title nn">Самовывоз</strong>
<div class="radio-input radio" id="su.pickup.pickup">
<label for="pickup.pickup"><input type="radio" name="shipping_method" value="pickup.pickup"
id="pickup.pickup" data-refresh="5" class="styled"> <span class=
"text">Самовывоз</span><span class="price">0 руб</span></label>
</div>
</div>
</body>
</html>