To obtain the length and width of the image, it is normal in IE and FireFox, so TMD won't work in Chrome. Some people say it is a problem in Chrome version, and finally found a solution, I would like to share with you the question of the length and width of the image to be obtained. It works normally in IE and FireFox, so TMD won't work in Chrome. If no one on the internet says yes, it also comes down to the Chrome version issue.
Finally, I found the answer.
In most cases, place the js Code behind the Image Tag:
The Code is as follows:
Script
Alert (document. getElementById ("test"). width;
《script》
In this way, the image width can be obtained, but not in Chrome.
In jquery:
$(document).ready(function(){
alert(document.getElementById("test").width;
});
In this way, Chrome still says no, I am C.
Then, Chrome nodded only in the following method:
$(window).load(function(){
alert($("#test").width());
});