My Jquery:
$("#leftmain").append("something");
<div id="leftmain">
// append text here
<p id="loading" >Loading ...</p>
</div>
How do I append the text just above the paragraph?
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.
You can use
.before():Which will add the new node just before the
#loadingelement: http://api.jquery.com/beforeOr you can use
.prepend():Which will add the new HTML as the first child element of the
#leftmainelement: http://api.jquery.com/prependHere is a demo showing how each of the methods I suggest work: http://jsfiddle.net/jasper/ndqpp/
Update
To fade-in dynamically created content you can set it to hidden by default then call
.fadeIn()on the new content:or if you use
.before():