[jQuery] Re: Getting Parent Element using "this"

2008-05-09 Thread briandichiara
. > > > -- Josh > > > - Original Message - > > From: "briandichiara" <[EMAIL PROTECTED]> > > To: "jQuery (English)" > > Sent: Thursday, May 08, 2008 1:58 PM > > Subject: [jQuery] Re: Getting Parent Element using "

[jQuery] Re: Getting Parent Element using "this"

2008-05-09 Thread hj
; <[EMAIL PROTECTED]> > To: "jQuery (English)" > Sent: Thursday, May 08, 2008 1:58 PM > Subject: [jQuery] Re: Getting Parent Element using "this" > > > Ok, I tried this: > > > $(elm).parents().map(function () { > > alert(this.tagName); > &g

[jQuery] Re: Getting Parent Element using "this"

2008-05-09 Thread Wizzud
If there is as little control over the markup as is implied then a more generic solution might be applicable (untested!)? function updateQuote(el){ //$('form') could be cached, and may not need to store parentForm... var parentForm = $('form').filter(function(){ var i = this.elements.le

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread Michael Geary
With markup as invalid as that, it's no surprise that elements are not where you expect them in to be in the DOM. A FORM element can't be sandwiched in between a TABLE and TR like that. So the browser tries to turn this into something it can work with. It may shuffle things around, or just put up

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread Josh Nathanson
ot;jQuery (English)" Sent: Thursday, May 08, 2008 1:58 PM Subject: [jQuery] Re: Getting Parent Element using "this" Ok, I tried this: $(elm).parents().map(function () { alert(this.tagName); }); but the FORM never shows up. Reason is because the source looks like this:

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread briandichiara
ok, i'm not sure if this is the easiest way, however, this is how I got the form action in the following HTML:

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread briandichiara
Ok, I tried this: $(elm).parents().map(function () { alert(this.tagName); }); but the FORM never shows up. Reason is because the source looks like this:

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread Michael Geary
> 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. Assuming you have a DOM element in 'th

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread briandichiara
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 Nathan

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread briandichiara
Also, i'd rather not "commit" anything i.e. using "name=blah" in case the name gets changed. without me knowing. 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 = n

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread briandichiara
what if the parent element is not a form. like: 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() { >

[jQuery] Re: Getting Parent Element using "this"

2008-05-08 Thread Josh Nathanson
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