Home > front end >  Access to events in the value of a variable
Access to events in the value of a variable

Time:12-12

How are the events outside the temp?

 $(function () {
Var temp="";
$(" # sort "). Change (function () {
Var temp=$(this). Val ();
});

The console. The log (" I value "+ temp);
});

CodePudding user response:

Only after the change event has been triggered temp assignment,
And the console. The log (" I value "+ temp); Is performed before the change event trigger, the temp haven't be assignment,

CodePudding user response:

The console must be executed in again after change event has been triggered. The log (" I value "+ temp); Only
 
$(function () {
Var temp="";
$(" # sort "). Change (function () {
Temp=$(this). Val ();
(aa);
});
The function (aa) {
The console. The log (" I value "+ temp);
}
});
  • Related