How to get real image width & height (cross browser) by JavaScript function ?
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to get the background from multiple images by
- void before promise syntax
jquery +
<img src="" ... id="hello" />
+$("#hello").width()
Yay, Google!
There's a few ways to do this depending on exactly what you need (which you have unhelpfully omitted to include). Probably the simplest in a general sense is to get a reference to the Image object and inspect the
width
andheight
properties.First of all, you have a greater chance of getting your question answered if you'd just ask it in a more polite way, and supplying as much relevant information as possible.
Anyway...
For as far as I know, you can use the
.width
property across pretty much all browsers: