Hbaecklund Hbaecklund - 10 months ago 56
jQuery Question

Change text to h1 with jquery?

How do I make the

2990 kr
text into an

<div class="productPrice">
<span>2 990 kr</span>

Alt 1 http://api.jquery.com/html/


Alt 2 http://api.jquery.com/text/



.wrapInner() method can be used.

Wrap an HTML structure around the content of each element in the set of matched elements.

$('.productPrice span').wrapInner('<h1 />')
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="productPrice">
<span>2 990 kr</span>