How to create parent element?

3

How to create a parent tag inside an element with jQuery, for example, having this original structure:

<p>texto</p>

After the jQuery function would look like this:

<a href='#'>
    <p>texto</p>
</a>
    
asked by anonymous 21.12.2016 / 15:52

1 answer

5

You can do this:

$('p').wrapAll('<a href="#" />');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<p>texto</p>
    
21.12.2016 / 16:00