I don't know why my reply's aren't showing up, but:

What if the first parent is not a form (like it could be a label or
div)? and also, I would like to avoid using the "name=something" just
because the name could change without me knowing it.

Thanks for the help.

On May 8, 2:30 pm, "Josh Nathanson" <[EMAIL PROTECTED]> wrote:
> jQuery is even easier than that.  You can remove the need to put your
> onchange inline like so:
>
> var formAction = null;
>
> $("select[name=some_name]").change(function() {
>     formAction = $(this).parent().attr("action");
>
> });
>
> This binds the anonymous function to set the variable formAction, to the
> change event of the select.
>
> -- Josh
>
> ----- Original Message -----
> From: "briandichiara" <[EMAIL PROTECTED]>
> To: "jQuery (English)" <jquery-en@googlegroups.com>
> Sent: Thursday, May 08, 2008 12:18 PM
> Subject: [jQuery] Getting Parent Element using "this"
>
> > I have a page where I need to get a parent forms action after firing
> > the onchange event on a select, like so:
>
> > <form action="something">
> > <select name="some_name" onchange="changeAction(this);">
> > <!-- some options -->
> > </select>
> > </form>
>
> > I can't figure out how to use "this" + a selector with jQuery,
>
> > I've tried
>
> > function changeAction(elm){
> >    var formAction = elm.$(":parent form").attr("action");
> > }
>
> > I really have no clue how to do effectively use "this" + a selector.

Reply via email to