Hbaecklund Hbaecklund - 1 year ago 107
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/


Answer Source

.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>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download