Two Laptop Bag*
The moose likes HTML, CSS and JavaScript and the fly likes Problem using text as a link for an expanding div. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Problem using text as a link for an expanding div." Watch "Problem using text as a link for an expanding div." New topic
Author

Problem using text as a link for an expanding div.

Ryan Christiani
Ranch Hand

Joined: May 15, 2011
Posts: 30
Hi,

I am working on a site for a job, wordpress site.

They want "..." to activate a expanding div with more info in it, code like such.



The ellipsis

The div that expands.



Problem is the "..." does not activate the script, does this have something to do with text as the element that has to be clicked? or have I just made some werid mistake?

Thanks


Probably going to ask a lot of possibly stupid questions...but how else will I learn? am I right!
Ryan Christiani
Ranch Hand

Joined: May 15, 2011
Posts: 30
Actually I solved it, sort of, but this just brings up some more questions.


I moved my span into the container that has the expanding div in it. In a case like this does the element to activate the script have to be right before the element that will be activated? Does that make sense, how can I have a link that toggles from another location?

Thanks.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
FYI that span is not keyboard accessible. I would have to use a mouse, not the best design. [aka use a link]

Why the original one failed

Description: Get the immediately following sibling of each element in the set of matched elements. If a selector is provided, it retrieves the next sibling only if it matches that selector.


detail is not a sibling.

With your adjusted code, you can call the code from anywhere with just:



You should also look at using document.ready instead of onload to attach the events.

Eric
Ryan Christiani
Ranch Hand

Joined: May 15, 2011
Posts: 30
Thanks for the info, link makes more sense, wasn't aware spans were not keyboard accessible.

I originally had it as,



but it would not load the script for some reason, from the net panel in firebug the page did fully load.

In terms of the detail sibling. So say I have this.



How would I go about setting that to expand. I am a little confused on that works, I have tried it and it did not seem to work out.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
One way would be



Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem using text as a link for an expanding div.
 
Similar Threads
Directory Structure JSP & JS
Fieldset is not working
Adding html tags to script
this.title returning undefined
Jack Up Browser Viewport