Add Heading Before dynamically created form field Jquery .insertBefore Add Heading Before dynamically created form field Jquery .insertBefore wordpress wordpress

Add Heading Before dynamically created form field Jquery .insertBefore


Add document ready to your code -

<script type="text/javascript">$(document).ready(function() {    $('<h5 class="form_title">Calculate Return</h5>').insertBefore('#price');});</script>


Looking at your page, I don't see where #price is defined. Maybe it is added later via JS and i missed it..

You are using jquery in no-conflict mode, and you need to wrap your code in document ready..

<script type="text/javascript">jQuery(document).ready(function() {    jQuery('<h5 class="form_title">Calculate Return</h5>').insertBefore('#price');});</script>

Running this; however, has no affect on the page(from what i can see).

The code below works because the ID exists. It isn't what you are trying to accomplish, but it should get you started.

<script type="text/javascript">jQuery(document).ready(function() {    jQuery('<h5 class="form_title">Calculate Return</h5>').insertBefore('#property_name');});</script>