Welcome visitor
* Login
* Register
It is currently January 22nd, 2019, 6:22 am
All times are UTC [ DST ]
* Search
View unanswered posts - View active topics

FORUMS » Client Side » HTML



Post new topic Reply to topic  [ 5 posts ] 
Author Message
  Image wont hide
PostPosted: April 24th, 2009, 5:10 am 

Posts: 24
I have two images on my site and each one has a button with the option to hide it. I found the script on the internet and it works fine for the first image, but when i add the second it keep hiding the first picture.

What should i do to hide the second?


Top
 Profile  
 
  Re: Image wont hide
PostPosted: April 24th, 2009, 5:22 am 
User avatar

Posts: 63
can we see your code?


Top
 Profile  
 
  Re: Image wont hide
PostPosted: April 24th, 2009, 5:28 am 

Posts: 24
sure, sorry i forgot it.
<div id="item1"><img src="it1.jpg"></div>
<input type="button" value="hide"
onClick="document.getElementById('item1').style.display= 'none';">                                       
<div id="item1"><img src="it2.jpg"></div>
<input type="button"  value="hide"
onClick="document.getElementById('item1').style.display= 'none';">


Top
 Profile  
 
  Re: Image wont hide
PostPosted: April 24th, 2009, 5:40 am 
User avatar

Posts: 63
the id is to name an element. u should not have two elements with the same id or you will have this problem.

to fix it just change the name, maybe item 2, both on the div tag and also on the get element by id parenthesis. So in the end you will have this,
<div id="item1"><img src="it1.jpg"></div>
<input type="button"  value="hide"
onClick="document.getElementById('item1').style.display= 'none';">                                       
<div id="item2"><img src="it2.jpg"></div>
<input type="button" value="hide"
onClick="document.getElementById('item2').style.display= 'none';">


Top
 Profile  
 
  Re: Image wont hide
PostPosted: April 24th, 2009, 5:48 am 

Posts: 24
:oops: ohhh, i see, thanks!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

FORUMS » Client Side » HTML


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron