Search code examples
javascriptjquerywordpressprepend

Prepend in WordPress/jQuery


I'm trying to prepend some content above an input form on my WordPress site using jQuery. I can get it to prepend, but then I can't style it because I'm not able to add a class or

tags with the code I'm using. I want to be able to prepend the text, then style it etc. Note: there is also some space that prepends with the text, so I'd like to be able to remove that as well.

My code so far:

<script>
(function()
{
jQuery('#frm_field_conf_87_container').prepend("* Confirm Email Address");
})();
</script>

Thanks in advance to anyone that can help!

What I'm seeing:

enter image description here


Solution

  • You can do something like this:

    jQuery('#frm_field_conf_87_container').prepend("<span class='your-class'>* Confirm Email Address</span>");
    

    Just used a span for the example, but you can use anthing you need to.