Skip to content Skip to sidebar Skip to footer

Cannot Read Property Isfocused of Null Discord

The front end page is not displayed, and an mistake is reported in the panel: Uncaught TypeError: Cannot read holding'length' of null

code show as beneath:

          <script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script> <!DOCTYPE html> <html> <head> <meta charset="utf-8">  <title>Test interface</title> </caput> <trunk>          <p>If at that place is no accident, the person'due south phone format will be displayed below. </p> 	<div id = "temp">       </div>   <script>     var information = [         {                          "proper name": "Zhang San",                          "sexual practice": "Male",             "telephone" : "12537487989999"         },{                          "name": "Li Si",                          "sexual activity": "Female",             "telephone" : null         },{                          "proper noun": "Wang Wu",                          "sex activity": "Female person",             "telephone" : "16483927649"         }     ]     var outStr = "";     for(var i = 0;i<data.length;i++){         if(information[i].phone.length != 11){                          outStr = outStr + data[i].proper name + "Phone number format error!";         }else{                          outStr = outStr + data[i].proper noun + "Phone number format is correct!";         }     }     $('#temp').html(outStr);   </script> </body> </html>        

This is considering the length holding cannot measure the length of null, considering zip is meant to be nothing, and there is no length property, so an error volition exist reported, so you are not sure whether a field may be null (especially when calling someone else'southward interface, the return value Not certain), but you also demand to use the length property to determine the length of this field. Yous'd amend utilise the length holding to add a layer of judgment to exclude the field is zero.

The modified code is as follows:

          <script src="https://cdn.staticfile.org/jquery/two.two.4/jquery.min.js"></script> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <championship>Test interface</championship> </head> <body>          <p>If at that place is no accident, the person's phone format volition be displayed below. </p> 	<div id = "temp">       </div>   <script>     var data = [         {                          "name": "Zhang San",                          "sex": "Male",             "phone" : "12537487989999"         },{                          "proper name": "Li Si",                          "sex activity": "Female",             "phone" : zero         },{                          "name": "Wang Wu",                          "sex": "Female",             "telephone" : "16483927649"         }     ]     var outStr = "";     for(var i = 0;i<data.length;i++){         if(data[i].telephone != goose egg){             if(data[i].telephone.length != 11){                                  outStr = outStr + data[i].proper noun + "Phone number format error!";             }else{                                  outStr = outStr + data[i].name + "Telephone number format is correct!";             }         }else{                          outStr = outStr + data[i].proper name + "Phone number is null!";         }     }     $('#temp').html(outStr);   </script> </body> </html>        

The results are as follows:

osbornclar1961.blogspot.com

Source: https://programmersought.com/article/10534079780/

Post a Comment for "Cannot Read Property Isfocused of Null Discord"