나는 단지 this
.toggle-bg
함수의 selector가 아닌 경우이 요소를 변경하십시오.
breakoff
을 변경하려면 노력하고 있어요 jQuery를
jQuery('.toggle-bg')
인 변화가 this
에 적용되는 동시에 breakoff
에 변경 사항을 적용 여기에 달성하기 위해 노력하고 모든
jQuery('.toggle-bg').on('change', function() { var value = jQuery('input.switch-id-value',this).val(), moon1 = jQuery('#' + value + '_0').is(':checked'), breakoff = jQuery('.line-break-off'), toggle = jQuery(this); toggle.css('background-color', (moon1 ? '#46b692' : '#333')); breakoff.each(function() { toggle.css('background-color', (moon1 ? '#46b692' : '#333')); }); }).trigger('change');
나는 이것이 작동하도록하는 몇 가지 것들을 가지고 있습니다. 예를 들면 다음과 같습니다 : .parent()
예를 들어 HTML을 보여 드리겠습니다. y oto는 breakoff
이 토글과 관련된 위치를 이해합니다.
HTML :
간단히<li class="top-header">
<div class="box-title">
<div class="section-icon fontawesome-twitter">
<span class="line-decor"></span>
<span class="line-break-off break"></span> //THE TARGET
</div>
</div>
// This is sloppy but this block below contains the toggle you get the idea..
// I dont have much experience using .parent() it kinda confuses me
// I am sure I need to nest my way out to target this.parent() .line-break-off
<div class="party">
<div class="control-block ">
<fieldset class="buttonset button-switch"><span class="toggle-bg" id="top-header" style="background-color: rgb(51, 51, 51);"><input type="radio" checked="checked" value="1" name="brashup[top-header]" id="top-header_0"><input type="hidden" value="top-header" class="switch-id-value"><input type="radio" value="0" name="brashup[top-header]" id="top-header_1"><input type="hidden" value="top-header" class="switch-id-value"><span class="switch ui-buttonset"><p class="switch-inner-bar"></p></span></span>
</fieldset>
<div class="bottom-box"><span class="description btn-desc">Here you can choose if you want a fixed header or not.</span>
</div>
</div>
</div>
</li>
넣어이 여러 토글의 목록입니다 및 특정 토글이 변경되는 동안 나는 클래스를 추가하여 부모 .line-break-off
을 조작 할, 또는 내가에서 걸릴 수 있습니다 CSS를 there :
나는 당신이 시도 확신하지만 여전히 매우 혼란스러운 방식으로 표현한 것 - 당신이 그것을 이해한다면 어쩌면 스스로를 읽고 보는 시도 너가 이미이지 않으면 그것을 연마 하십시요? 당신이 10 살짜리로 설명해야만한다면 - 너는 무엇을해야 할까? 어떻게 할거 니? jsfiddle.net의 바이올린도 꽤 자주 도움이됩니다. –
죄송합니다. 제 질문을 읽은 후에 죄송합니다. 정말로 혼란스럽고 복잡합니다. 질문의 첫 번째 문장을 업데이트했습니다. * 여기서 달성하고자하는 것은 변경 사항을 jQuery ('. toggle-bg')와 동시에 적용 할 때 변경 사항을 적용하는 것입니다. * –
breakoff는 jQuery의 var입니다 ('line-break-off') –