javascript - How to add characters before and after h2 innerhtml -
i've scoured ways this, i'm missing obvious, , sorry.
i'm trying add 2 characters h2
element. have done, if more 1 h2
first 1 copied. unique innerhtml of each h2
have these characters added before , after.
i aware css have before , after on element doing other things.
$(window).on("load", function() { // on page load, add greater , less signs h2s var regh2 = $('h2').html(); $('h2').html( '<' + regh2 + '>' ); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <h2>header1</h2> <h2>header2</h2>
try this
$('h2').each(function(){ var regh2 = $(this).html(); $(this).html( '<' + regh2 + '>' ); });
Comments
Post a Comment