Hi Ricardo,

Thanks for the reply. Unfortunately there are multiple fields which
all need independent error messages - sticking into a class would
trigger the same error message for all inputs. :-)



On Oct 17, 4:35 am, ricardobeat <[EMAIL PROTECTED]> wrote:
> You shouldn't rely on this kind of 'navigation' for the exact reasons
> you are having problems. Elements in the DOM will change positions
> everytime you manipulate them, this relative navigation is prone to
> errors. Base your code on IDs, classes and think always from the top
> to bottom (parent > children), using the parent as reference.
>
> For example, why not just stick a class="error" in a <div> and place
> your stuff with $('.error').append(errorMessage) ?
>
> - ricardo
>
> On Oct 16, 4:55 am, Jub <[EMAIL PROTECTED]> wrote:
>
> > Hi gang,
>
> > I'm just coming across to jQuery and trying to figure out the best way
> > to dynamically navigate the DOM. Where there's an element object, I'm
> > happy with parent() and next(), but in functions that don't reference
> > an element object, I'm a little confused. Here's some clarification:
>
> > errorPlacement: function(error, element) {
> >   error.appendTo( element.parent().parent().next().next());
>
> > });
>
> > I'm happy and fine with this. However:
>
> > success: function() {
> >   "want to do a similar
> >   --> 'this' works here, but 'element' is blank. this.parent()/
> > this.next() returns an error.
>
> > Any suggestions appreciated - cheers. :-)
>
> >  - Jub

Reply via email to