When I say, msg.appendTo(ele.parent().next()), the msg successfully gets appended to a <p> with class=foo
How can I specify it explicitly in the statement?
I tried msg.appendTo(ele.parent().next().find('.foo'));
but it doesn’t work
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question is not totally clear, but maybe you are looking for
.siblings():Explanation:
Your code
msg.appendTo(ele.parent().next())will appendmsgto the next sibling of the parent element ofele.Whereas
msg.appendTo(ele.parent().next().find('.foo'))will appendmsgto all elements with classfooinside the next sibling of the parent element ofele.Whenever you are uncertain about how a method works, read the documentation first. Most questions will be covered by it.
Documentation of
.appendTo().Also you should probably read about how
.next(),.find(), etc. work.