PDA

View Full Version : CSS property/class similar to onClick event?



gohankid77
Sep 11th, 2004, 05:42 AM
I'm wondering if there is a CSS property or CSS class which acts in a similar manner to the onClick event attribute (which allows scripts to be called) of HTML. I have a hidden block of text that when a certain item is clicked will be displayed. It is kind of like this:



...
<li onclick="document.getElementById('foo').style.display: block; return false">Show foo</li>
...


Many users have JavaScript disabled, so the above method will not work. Is there something like this (on the client side)?

tsguitar2004
Sep 11th, 2004, 05:59 AM
Would a hover combined with display: none; / display: block; work?? Kind of like this: http://www.meyerweb.com/eric/css/edge/popups/demo.html? If you want it to happen with the click of the mouse, I don't think there's CSS for that. That's javascript-land.
-ts

gohankid77
Sep 11th, 2004, 06:38 AM
Nope. :hover won't work because I will have a list of letters of the alphabet. When a letter is clicked, items beginning with that letter will be displayed. I got a suggestion to use :focus, but I'm also trying to make this cross-browser compatible. This is even harder since JavaScript cannot be used. Thank you for replying tsguitar.

bradyj
Sep 11th, 2004, 07:42 AM
Why couldn't you do a hover then? You would just give each separate link a different id, I thought that would work from what I'm envisioning, but I may not be seeing it right :)

mindlessLemming
Sep 11th, 2004, 08:12 AM
using :active in conjunction with :focus will get IE to respect your author-i-tie. :D

tsguitar2004
Sep 11th, 2004, 08:31 AM
http://www.htmldog.com/articles/suckerfish/
http://www.htmldog.com/articles/suckerfish/dropdowns/example/
I'm sure you've seen these articles before, but could you do something like a CSS dropdown menu? Rollover each letter of the alphabet and the list drops down? That's another thing I was thinking of when I suggested :hover.
-ts

P.S. And it was my pleasure to respond, gohan. Thank *you* for acknowledging my effort. A pleasant day to you, sir. :thumbsup:

gohankid77
Sep 11th, 2004, 05:30 PM
using :active in conjunction with :focus will get IE to respect your author-i-tie. :D

really? hmm... let me try that... Wait a minute...

This may seem like a really dumb question, but how would you do that? Once a link is active, how would you display another item?