replace - Use javascript to add style to every digit in a string -


here's js code:

<script language='javascript' type='text/javascript'>     var myoldstring = "1,2,3,4,5,6</br>1,2,3,4,5,6</br>1,2,3,4,5,6"     var mynewstring = myoldstring.replace(/,/g , " ");     document.write(mynewstring); </script> 

works fine, need add style="padding:5px" every digit.

i tried lot of different code vairations none of them work.

thank's help!

do mean that?

<script language='javascript' type='text/javascript'> var myoldstring = "1,2,3,4,5,6</br>1,2,3,4,5,6</br>1,2,3,4,5,6" var  mynewstring = myoldstring.replace(/([0-9]+),?/g , ' <span style="padding:5px">$1</span> '); document.write(mynewstring);</script> 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -