私はうまく動作するスクリプトを持っていますが、別の値で背景の位置を変更する2番目のタグを追加する必要があります。 $( '#box_inputR')を追加する必要があります。css( 'background-position'、 '0 -39px');さらに、を既存のスクリプトに追加します。IF文にTWOイベントを追加する...助けが必要です!
これで、ifステートメントの結果として2つのタグが変更されるようになりました。あなたはどうしますか? ANDはありますか?
<script type="text/javascript">
$(function() {
$('#fastContact').formValidator({
scope : '#cform',
errorDiv : '#errorDiv2',
onError : function() {
if ($('#box_inputA input').hasClass('error-input')) {
$('#box_inputA , #box_inputR').css('background-position','0 -39px');
} else {
$('#box_inputA , #box_inputR').css('background-position','0 0');
}
if ($('#box_inputB input').hasClass('error-input')) {
$('#box_inputB , #box_inputR').css('background-position','0 -39px');
} else {
$('#box_inputB , #box_inputR').css('background-position','0 0');
}
if ($('#box_inputM textarea').hasClass('error-input')) {
$('#box_inputM').css('background-position','0 -84px');
$('#box_inputR').css('background-position','0 -39px');
} else {
$('#box_inputM').css('background-position','0 0');
$('#box_inputR').css('background-position','0 0');
}
}
});
});
</script>
を。 ifを閉じてelseに入る前に、anotheステートメントを発行することができます。 – diagonalbatman
ええと...あなたは 'if'の中でもう一方の文の後に1つの文を入れてみましたか?なぜあなたは '{}'が必要だと思いましたか? ;) –