View Single Post
Old 12-24-2011, 02:22 AM   PM User | #7
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 454 Times in 452 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
no, that's not going to work - getElementsByTagName returns a collection, even if there is only one element in the collection. You can select it like this:

Code:
function plus() {
thepic=document.getElementsByTagName('img')[0]
thepic.style.width= parseInt(thepic.style.width)+200+"px";
}

function minus() {
thepic=document.getElementsByTagName('img')[0]
thepic.style.width= parseInt(thepic.style.width)-200+"px";
}
but that will only work on the first image on your page. do you want to be able to resize all the images with one button click, or to have multiple buttons, each of which resize a specific image?
xelawho is offline   Reply With Quote
Users who have thanked xelawho for this post:
Charlie8776 (12-24-2011)