Wrap dollar values in a span with jQuery? -


i've got bunch of h4 tags want wrap in <span class="red"> </span>

some of text this: $12 , has space $ 5

how can wrap instances of $ , numbers follow jquery?

let me clarify. want have <h4> item <span class="red">$42</span> , on sale</h4>

i regular expression. like:

 var tempstring = $("h4").html().replace(/^(.*)(\$\s*\d+)(.*)$/, '$1<span>$2</span>$3'); $("h4").html(tempstring); 

the regular expression might need modification depending on situation. in second part of replace, put '$2' inside span tags class want add.


Comments

Popular posts from this blog

silverlight - Applying a style to ItemContainerStyle in C# -

c# - NullReferenceException in MySqlClient.NativeDriver -

php - Updating recent updates - Problem in procedure - Any other approach? -