To insert html content at the beginning of an element, prepend()
method can be used
<script> $("#div2").prepend("Prepending text : "); </script>
Above code snippet will insert specified string at the beginning of the element “div2” element.
For example, below code
<div id="div2" class="class1">Demo of <b>attr</b> attribute</div>
Will change to
<div id="div2" class="class1">Prepending Text : Demo of <b>attr</b> attribute</div>
After executing the above prepend statement (notice the bold text).
Views: 5085 | Post Order: 32