jquery를 사용하면 spzn에서 rgb 색상 코드를 이전에 클릭 한 코드로 가져 오려고합니다.이전 스팬 요소에서 스타일 가져 오기
나는이와 함께 클릭을 얻을 수 있습니다 :
$(document).ready(function(){
$("#myDiv :radio").click(function(){
alert("Got here");
});
});
그래서, 클래스 swatchColour_1 전에 라디오 버튼과 범위에서 RGB 코드 번호 000000을 얻는 방법에 대해 설명합니다.
다양한 색상의 약 30 가지 요소가 있습니다. 내가 실제로 변경할 수있는 유일한 코드는 id = "myList"인 첫 번째 div입니다.
<div class="productAttributeList" id="myList" style="">
<div class="productAttributeRow xx" id="ffb492067dcd98c19b6be89e9230f4fc">
<div class="productAttributeLabel">
<label for="06b0854950dd6cc1d296718965c0d36a">
<span class="required">*</span>
<span class="name">Color choice:</span>
</label>
</div>
<div class="productAttributeValue">
<div class="productOptionPickListSwatch">
<ul>
<li class="swatch hasPreview swatchOneColour">
<label for="0780a439a3a2ec8492a8772f4f5d739a">
<span class="previewContent">
<span class="swatchColours swatchOneColour showPreview" title="Black - 070">
<span class="swatchColour swatchColour_1" style="background-color:#000000;"> </span>
</span>
</span>
<input type="radio" class="validation" name="attribute[119]" value="195" id="0780a439a3a2ec8492a8772f4f5d739a" />
<span class="name">Black - 070</span>
</label>
</li>
입니다. . .
감사 게리
_ # 000000_은 (는) rgb가 아닙니다. – undefined
이런 식으로 - http://jsfiddle.net/elen/Y4HSP/ - 당신은'input :'을 놓쳤다. 특히 더 많은 버튼을 추가하는 경우'change() '를 사용하는 것이 더 좋다. – Elen
라디오 버튼 값 속성을 사용하는 것이 더 쉽다. 저장소를 찾으십시오. 그러나, span을 찾으십시오. http://jsfiddle.net/elen/Y4HSP/1/ – Elen