I have a form with 20 input fields.
Each input field is inside a DIV
I have a script that changes the background color of the DIV via keyup function along with two other DIV tags.
Rather than duplicating the script 20 times for each DIV and Input, is it possible to re-write the script to do all DIV's and their Inputs?
<script>
$(document).ready(function(){
$("#id").keyup(function() {
if($("#id").val().length > 0) $("#in1, #nu1, #lw1, #id").css("background-color",
"#2F2F2F").css("color", "#FFF");
else {
if($("#id").val().length == 0) $("#in1, #nu1, #lw1, #id").css("background-color",
"#E8E8E8").css("color", "#000");
}
});
});
</script>