开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜