죄송합니다 ... 이런 질문이 수백 개 있다는 것을 알고 있습니다 ...하지만 제가하려는 일에 대한 답을 찾지 못했습니다.
CSS
.inputtable {
background-color: #ffff66; // yellow
}
.inputtable[ disabled ] {
background-color: #ddd; // greyed-out
}
JQuery
ajaxGetAddresses.done(function( data, textStatus ) {
console.log( 'data length: ' + data.length );
// clear the select
var s2 = $( '#add_select' );
s2.empty();
if( data.length > 1 ){
// ... select will be "live"
s2.prop( 'disabled', false );
//s2.css( 'background-color', '#ffff66' );
s2.css( 'background-color', '.inputtable background-color' );
} else {
s2.prop( 'disabled', true );
// s2.css( 'background-color', '#ddd' );
s2.css( 'background-color', '.inputtable[disabled] background-color' );
}
이것이 의미가 있기를 바랍니다. 0 또는 1 개의 요소 (배열) 가 있으면이 기능을 비활성화 data
하고 싶습니다 SELECT
. 그리고 회색 배경이 있습니다. 그렇지 않으면 노란색 배경을 사용하여 사용할 수 있음을 나타냅니다.
설정을위한 "하드 코딩 된"버전의 css 명령이 background-color
제대로 작동합니다. background-color
이 클래스 에서 값을 "검색"하는 방법을 알아낼 수 없습니다 (일반 및 비활성화).
추가 세부 정보
HTML은 다음과 같습니다.
<div id="div1" >
<div id="select_div" ><u>S</u>elect:
<select id="secondname_dropdown" size="1" class="inputtable" ></select>
</div>
</div>
...
<div id="address_number">
Address <select id='add_select' class='inputtable' ></select>
of <span id='number_of_addresses' ></span>
</div>
이것이 도움이 될 수 있습니다.
ajaxGetAddresses.done(function( data, textStatus ) {
console.log( 'data length: ' + data.length );
// clear the select
var s2 = $( '#add_select' );
s2.empty();
if( data.length > 1 ){
// ... select will be "live"
s2.prop( 'disabled', false );
//s2.css( 'background-color', '#ffff66' );
s2.addClass( 'inputtable' );
} else {
s2.prop( 'disabled', true );
// s2.css( 'background-color', '#ddd' );
s2.addClass( 'inputtable').attr("disabled", 'disabled');
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다