The forums ran from 2008-2020 and are now closed and viewable here as an archive.
I have a page with a link, that I want that everytime a user clicks on it – it opens a div with content on it.
How do I do this using CSS ?
Is it more recommended to do this using JS?
One thing though, unless you need an actual link to the div, you shouldn’t use an href…
If all the thing does is open a div on the same page, use a button styled how you like.
you are right about the href thing.
That’s why I used: “preventDefault”
Here is a JSfiddle with a code I made as an example.
Maybe my post will help somebody else :)
I think what Paulie is suggesting is to not use an anchor at all. You can attach a click event to any element. In your case I’d probably use a <span>.