coolispaul
asked on
Selecting an element with jquery
Hi
I have an html page with attached code in. When i click the anchor link (id = "click6") i want to select the div that is directly previous to it . (the one that has display none)
How can i do that with jquery?
Thanks
I have an html page with attached code in. When i click the anchor link (id = "click6") i want to select the div that is directly previous to it . (the one that has display none)
How can i do that with jquery?
Thanks
<div style="width:590px; float:right; margin-top:32px;">
<p>content...</p>
<div style="display: none">
<p>Content<p>
</div>
<p><a id="click6" name="click">EXPAND BIO</a>.</p>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great yes it works with parent()
Why doesnt $(this).prev("div") work? thats actually what i tried..
Cheers
Why doesnt $(this).prev("div") work? thats actually what i tried..
Cheers
because anchor is inside the <p> and is not at the same level as div
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
oh ok i thought .prev(div) just looked for the previous "div" element in the HTML regardless of being sibling or not.
Ok thanks
Ok thanks
$("a#click6").bind("click"
$(this).prev("div").css("b
});