I have a script that works fine, but I need to add a second tag that changes background position at a different value. I need to add $(‘#box_inputR’).css(‘background-position’,’0 -39px’); in addition to the existing script.
So now two tags change as a result of the if statement instead of one. How would you do this? Is there an 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>
Try this. My syntax may be off. I don’t really know Javascript at all.