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

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -