English 中文(简体)
Java字:获得 im子的宽度
原标题:Javascript: getting the width of an img element

使用 Java 我得以在我的html文件中选择了图像要素(hexachloromageElement Object, 即img1)。 我也可以使用<代码>img1.e。 然而,以下人员返回了空白警报:

alert(img1.e.width);

而同一职位使用的是:

alert (img1.width);

so I don t think it s a problem with the image not having loaded yet.

我可以使用两种选择中的两种选择中的任何一个,但我当然喜欢使用第一个选择。 但是,为什么能打上Iget。 第一次使用宽度?

这不是我想要在这里完成的任务(我可以这样做,其次);我想首先了解什么错误。

最佳回答

<代码>img1. 风格.width 页: 1 如果你没有一刀切的规则,该财产就是空洞的。

问题回答

These are references to two different ways of setting an <img> width:

  • You can set in in the HTML attributes, through <img width="100px"> for example.
  • You can set it for a style or a class that your <img> will belong to, through CSS.

The first one is accessed through img.width. The second one through img.style.width.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签