jquery - Prepend a number with $ in javascript -


i have small script ( using nouislider )

i wish prepend rangething values $ sign outputting prices.

code have is:

$("#slider").nouislider({ range: [0, 1000000] ,start: [350000, 700000] ,handles: 2 ,step: 50000 ,slide: function(){   var values = $(this).val();   $("span.rangething").text(      values[0] +      " - " +      values[1]   );  }  ,serialization: {   to: [$("#exto"),$("#exfr")]   ,resolution: 1  }  });  

the javascript creates span <span class="rangething"></span>

the output format 200000 - 350000

i format ( commas ) thousand separators, thats gonna messy. trying prepend 2 sets of values $ sign signify price.

so resultant output $200000 - $350000

i tried changing values this, didnt work lol.

$("span.rangething").text(      + "$" + values[0] +      " - " +      + "$" + values[1]   ); 

i not sure if on right track, , fact trying echo $ culprit, , perhaps should use unicode, either way isnt working.

help appreciated

do in 1 line see what's going on:

  • you starting +
  • the third line has double +

one line easier read:

$("span.rangething").text("$" + values[0] + " - $" + values[1]); 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -