HTML
<textarea id="photo-42-9" class="comment_box">Write a comment...</textarea>
jQuery code that doesn’t work, what am I missing?
$('#photo-42-9').prepend("<div>blah</div>");
EDIT
Corrected the ids mismatch, still doesn’t work though
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.
prepend()adds the specified mark-up into the object returned by the jQuery selector (in this case thetextarea). Atextareacan contain only text, no other child elements; therefore you’re trying to create invalid html.If you want to put the
<div>before thetextarea:If you want to prepend new text into the
textarea:References:
prepend().insertBefore().val().