Home > front end >  Understand the confusion about the code
Understand the confusion about the code

Time:03-16

Want to consult with the if the following code (/[^ \] d/. The test (even) target) value)) {.. This part, my own understanding is to judge whether the values, if yes, the background is red otherwise empty, but the real test is the other way round, where is want to consult with understanding is wrong, thank you


Window. The onl oad=function () {
Var form=document. Forms [0];
Form. The elements [0]. AddEventListener (" focus ", handler);
Form. The elements [1]. The addEventListener (" focus ", handler);
Form. The elements [0]. AddEventListener (" blur ", handler);
Form. The elements [1]. The addEventListener (" blur ", handler);
Form. The elements [0]. AddEventListener (" change ", handler);
Form. The elements [1]. The addEventListener (" change ", handler);

The function handler (even) {
If (even type=="focus") {
If (even) target) style backgroundColor! {
="red")Even the target. Style. BackgroundColor="yellow";
}
} else if (even) type=="blur") {
If (even) target) style backgroundColor! {
="red")Even the target. Style. BackgroundColor="";
}
} else if (even) type=="change") {
If (/[^ \] d/. The test (value) even. Target.) {
Even the target. Style. BackgroundColor="red";
} else {
Even the target. Style. BackgroundColor="";
}
}
}
}
</script>

<body>