jquery tree traversing help
Update: I'll have to go back to the drawing board on this one. Thanks for all the feedback.
Hi All,
Given simple DOM:
<form id="form1">
...
</form>
<div>
<div>
<a href="#" id="export">Export</a>
</div>
</div>
Starting 开发者_如何学Gowith id=export, is there a way to go up a variable amount of divs and then get the closest form id?
Thanks, rodchar
EDIT: You can try this, assuming the form has no parents:
alert($(this).parents(":last").prevAll("form:first")[0].id);
I think you will need to show more relevant document structure, as others have pointed out.
精彩评论