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

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -