If i have:
<div id="test"></div>
How do I select the test div and then add <div id="pre-test"> before the test div so it looks like this:
<div id="pre-test"><div id="test"></div>
Thanks guys
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.
$("<div id='pre-test'/>").insertBefore("#test");insertBefore documentation.
Alternatively, you can use the
.before(...)method like so:$("#test").before("<div id='pre-test'/>");