2012-05-12 26 views
0

いくつかの理由から、このjavaScriptコードをハイライト行に使用しています。このコードブロックに条件を追加する必要があります。条件でJavaScriptを使用して行の色を変更する方法は?

function onGridViewRowSelected(rowIdx, rowIdx2) { 
    //bring value via get control and assign 
var selRow = getSelectedRow(rowIdx); 
//Check Current Row is null or not 
if (curSelRow != null) { 
    //..TRIED THIS ROW 
    if (curSelRow.style.backgroundColor = '#red') { 
     //do nothing.. 
    } else { 


     curSelRow.style.backgroundColor = '#ffffff'; 
    } 
} 
//come to here if not in condition and check selected row is null or not 
if (null != selRow) { 
//if in condition .. 
    curSelRow = selRow; 
    //change current selected row background color 
    curSelRow.style.backgroundColor = '#ababab'; 
} 

}

+2

あなたの質問は何ですか?このような何かあなたのjavascriptにはいくつかの問題があります。まず、if条件は '='ではなく '=='や '==='を使うべきです。 – jfriend00

+0

... '#red'は動作しません。 #を削除する必要があります。 – x1a4

答えて

0

私もあなたの質問について明確ではないですが、あなたのJSコードにバグがあります:

if (curSelRow.style.backgroundColor = '#red') // WRONG, u can't do this 
if (curSelRow.style.backgroundColor == '#red') // use color codes instead (for red = #ff0000) or just red.. 
関連する問題