jquery get background image width and height

<Script type = "text / JavaScript">
/ * get the background * /
var URL = $ ( 'wrap.') ( 'the backgroundImage') CSS;.
/ n * unnecessary information is deleted, the image retention links * /
var S = url.match (/ url \ ((*) \) /.?);
/ * return a data, the first one is the original picture link, the second link is to delete the unwanted stuff * /
S = URL [. 1];
/ * remove the head with the end of the quotation marks * /
IF (URL [0] == "\" ") {URL url.slice = (. 1, -1); the console.log (URL)}
/ * put the picture link img instances get inside aspect, the use of onload can only go back picture after picture finished loading height to width * /
$ ( "<img />"). attr ( "src", url). Load (function () {
realWidth = this.width;
realHeight = this.height;
the console.log (realWidth);
});
</ Script>

Guess you like

Origin www.cnblogs.com/zjhuanjing/p/11884235.html