我有以下代码(由Magento动态创建),我需要突出显示已选中的单选按钮标签。
我该怎么做?我尝试使用图像替换脚本来实现使用Mootools运行的单选按钮,但这与magento核心中的prototype.js冲突。
我需要的是能够更改所选选项标签上的突出显示,因此请在所选标签上添加边框等。
有人能指出我正确的方向吗?
<div class="product-options-title">
<dt>
<label class="required"> <em>*</em> Edge Details</label>
</dt>
</div>
<div class="product-options-chooser">
<dd class="options-last">
<div class="input-box">
<ul id="options-3318-list" class="options-list">
<li>
<input type="radio" class="radio validate-one-required-by-name product-custom-option" onClick="opConfig.reloadPrice()" name="options[3318]" id="options_3318_2" value="548258" price="0" />
<span class="label">
<label for="options_3318_2">
<img src="http://www.justkitchens.co/media/doors/zurfiz/zurfiz_ultragloss_black_matching.jpg" />
<div class="edge-option">Matching</div>
</label>
</span><script type="text/javascript">$('options_3318_2').advaiceContainer = 'options-3318-container';$('options_3318_2').callbackFunction = 'validateOptionsCallback';</script></li>
<li>
<input type="radio" class="radio validate-one-required-by-name product-custom-option" onClick="opConfig.reloadPrice()" name="options[3318]" id="options_3318_3" value="548259" price="0" />
<span class="label">
<label for="options_3318_3">
<img src="http://www.justkitchens.co/media/doors/zurfiz/zurfiz_ultragloss_black_brushed_steel.jpg" />
<div class="edge-option">Stainless Steel Effect</div>
</label>
</span><script type="text/javascript">$('options_3318_3').advaiceContainer = 'options-3318-container';$('options_3318_3').callbackFunction = 'validateOptionsCallback';</script></li>
<li>
<input type="radio" class="radio validate-one-required-by-name product-custom-option" onClick="opConfig.reloadPrice()" name="options[3318]" id="options_3318_4" value="548260" price="0" />
<span class="label">
<label for="options_3318_4">
<img src="http://www.justkitchens.co/media/doors/zurfiz/zurfiz_ultragloss_black_glass.jpg" />
<div class="edge-option">Glass Effect</div>
</label>
</span><script type="text/javascript">$('options_3318_4').advaiceContainer = 'options-3318-container';$('options_3318_4').callbackFunction = 'validateOptionsCallback';</script></li>
</ul>
<span id="options-3318-container"></span> </div>
</dd>
</div>
答案 0 :(得分:3)
你可以这样做(我使用直播,因为内容是生成的):
$('input:radio').live('click', function(){
if($(this).is(':checked')){
$(this).next('span').addClass('border');
}else{
$(this).next('span').removeClass('border')
}
});
然后定义一个css类:
label.border{
border: 1px solid red;
}