Uncaught Typeerror: Cannot Read Property 'getboundingclientrect' of Null
The front folio is not displayed, and an error is reported in the console: Uncaught TypeError: Cannot read holding'length' of naught
code show equally beneath:
<script src="https://cdn.staticfile.org/jquery/2.2.4/jquery.min.js"></script> <!DOCTYPE html> <html> <caput> <meta charset="utf-viii"> <title>Test interface</title> </head> <torso> <p>If at that place is no blow, the person's phone format volition be displayed below. </p> <div id = "temp"> </div> <script> var data = [ { "name": "Zhang San", "sexual activity": "Male person", "telephone" : "12537487989999" },{ "name": "Li Si", "sex": "Female", "telephone" : null },{ "name": "Wang Wu", "sexual activity": "Female", "phone" : "16483927649" } ] var outStr = ""; for(var i = 0;i<data.length;i++){ if(information[i].telephone.length != 11){ outStr = outStr + data[i].name + "Telephone number format error!"; }else{ outStr = outStr + information[i].name + "Phone number format is correct!"; } } $('#temp').html(outStr); </script> </torso> </html> This is considering the length property cannot measure the length of zip, considering null is meant to exist cypher, and in that location is no length property, so an error will be reported, so you are not sure whether a field may be nix (especially when calling someone else's interface, the return value Not sure), but you besides need to employ the length holding to determine the length of this field. You'd better use the length property to add a layer of judgment to exclude the field is zilch.
The modified code is as follows:
<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> </head> <body> <p>If there is no accident, the person's telephone format will be displayed below. </p> <div id = "temp"> </div> <script> var information = [ { "name": "Zhang San", "sexual practice": "Male", "telephone" : "12537487989999" },{ "name": "Li Si", "sex activity": "Female", "phone" : null },{ "name": "Wang Wu", "sex": "Female", "telephone" : "16483927649" } ] var outStr = ""; for(var i = 0;i<data.length;i++){ if(data[i].telephone != null){ if(data[i].telephone.length != 11){ outStr = outStr + data[i].proper name + "Phone number format error!"; }else{ outStr = outStr + data[i].name + "Telephone number format is correct!"; } }else{ outStr = outStr + data[i].name + "Phone number is zero!"; } } $('#temp').html(outStr); </script> </body> </html> The results are as follows:
Source: https://programmersought.com/article/10534079780/
0 Response to "Uncaught Typeerror: Cannot Read Property 'getboundingclientrect' of Null"
Post a Comment