javascript - How do I force jQuery to not automatically close a tag? -
i have link , want create nav
tag before link tag, close after a
tag.
code:
<a href="" id="test">link test</a>
i want code this:
<nav class="link-effect"> <a href="" id="test">link test</a> </nav>
i tried following .before()
, .after()
, .append()
, .prepend()
closing tag created automatically.
use .wrap
function of jquery.
$( "#test" ).wrap( '<nav class="link-effect"></nav>' );
please check below snippet.
$( "#test" ).wrap( '<nav class="link-effect"></nav>' );
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a href="" id="test">link test</a>
Comments
Post a Comment