Jump to content

Display hidden text with onclick


METOOTECH

Recommended Posts

Hi again, my new problem is that I'm trying to get some hidden text in a div or p tag to display when targeted by a button or an a (anchor) tag code. Here the code I have..... it doesn't work, I've tryed setting it up in a p tag and a div tag and tried to target it with a button tag and with an anchor (a) tag. No problem hidding the text, but can't get it to display when clicked on. Please help! ...METOOTECHTHE CODE:<div id="d" style="display: none">TEXT YOU CANNOT SEE </div> TEXT YOU CAN SEE<br><br><button id="b1" style="display: inline" onclick="d.style=this.style">CLICKER </button>

Link to comment
Share on other sites

Change the line in red below and it will work. :) -----------------------<div id="d" style="display: none">TEXT YOU CANNOT SEE </div> TEXT YOU CAN SEE<br><br><button id="b1" style="display: inline" onclick="d.style.display='block'">CLICKER </button>

Link to comment
Share on other sites

Change the line in red below and it will work. :) -----------------------<div id="d" style="display: none">TEXT YOU CANNOT SEE </div> TEXT YOU CAN SEE<br><br><button id="b1" style="display: inline" onclick="d.style.display='block'">CLICKER </button>

Again, thanks for the help. I'm pretty good with HTML, CSS, etc. but inline javascript syntax eludes me... the reason I use inline script is because a lot of this goes into ebay ads and about me pages and their description editor blocks regular scripts. I work around this usually with inline script. I have been using textarea tags, but other than the initial style tag at the beginning, you don't much control of the way the text is displayed in the textarea.By the way, which browsers will be able to see the results of the above code? METOOTECH
Link to comment
Share on other sites

Again, thanks for the help. I'm pretty good with HTML, CSS, etc. but inline javascript syntax eludes me... the reason I use inline script is because a lot of this goes into ebay ads and about me pages and their description editor blocks regular scripts. I work around this usually with inline script.  METOOTECH

No ProblemYes that right, when using ebay etc you will need to use inline scripts/styles. But something to consider for the future, inline scripts/styles are on the way out (if not already) so at somepoint you wont be able to use them. I wouldn't worry to much just now though cause they won't be dropped by browsers anytime in the near future.
Link to comment
Share on other sites

No ProblemYes that right, when using ebay etc you will need to use inline scripts/styles.  But something to consider for the future, inline scripts/styles are on the way out (if not already) so at somepoint you wont be able to use them.  I wouldn't worry to much just now though cause they won't be dropped by browsers anytime in the near future.

I have been using textarea tags, but other than the initial style tag at the beginning, you don't much control of the way the text is displayed in the textarea.By the way, which browsers will be able to see the results of the above code? METOOTECH
Link to comment
Share on other sites

I have been using textarea tags, but other than the initial style tag at the beginning, you don't much control of the way the text is displayed in the textarea.By the way, which browsers will be able to see the results of the above code? METOOTECH

Without checking i'm 100% certain will work with IE, FF and Opera.The code should work on many more though.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...