139
rated 0 times
[
145]
[
6]
/ answers: 1 / hits: 27013
/ 13 Years ago, thu, april 28, 2011, 12:00:00
Here is my html
<a href=index.php><img id=testimg src=images/logo.png/></a>
Here is my javascript
function getW(){
var theImg = document.getElementById('testimg');
return theImg;
}
theImg = getW();
if (theImg.width > 119){
document.write(theImg.width);
}
Now when I use this script it out puts the img width
However when I use this script
function getW(){
var theImg = document.getElementsByTagName(img);
return theImg;
}
theImg = getW();
if (theImg.width > 119){
document.write(theImg.width);
}
It doesn't output anything. What is the difference and why would this 2nd script work?
Thanks!
More From » javascript