Reputation: 2698
I'm working on a function that process form data through ajax. I've got the function written, but in the end, once I've got the data, I need to put a message into a div within the submitted form. The div has a class of 'message'.
When referring to the form as $(this)
in my function, how would I get to the div with the class of "message" within it? (So the equivalent of $('form.message')
, but using $(this)
instead of form)
Upvotes: 2
Views: 80
Reputation: 4371
Give your selector context:
$(".message", this);
That's all :)
Upvotes: 4
Reputation: 7712
Try
$(this).children('.message')
Depending on the structure/lay out of your html this should work.
If not you should post your html so we can have a better idea of what your trying to do.
Upvotes: 2