我有这个脚本由另一个stackoverflow的成员制作但我需要为数千个数字设置一个逗号分隔符。
我怎么能这样做?
(function($) {
$.fn.currencyInput = function() {
this.each(function() {
var wrapper = $("<div class='currency-input' />");
$(this).wrap(wrapper);
$(this).before("<span class='currency-symbol'>$</span>");
$(this).change(function() {
var min = parseFloat($(this).attr("min"));
var max = parseFloat($(this).attr("max"));
var value = this.valueAsNumber;
if(value < min)
value = min;
else if(value > max)
value = max;
$(this).val(value.toFixed(2));
});
});
};
})(jQuery);
$(document).ready(function() {
$('input.currency').currencyInput();
});
.currency {
padding-left:12px;
}
.currency-symbol {
position:absolute;
padding: 2px 5px;
}
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<input type="number" class="currency" min="0.01" max="2500.00" value="25.00" />
答案 0 :(得分:2)
import QuartzCore
&#13;
var that = this,
map_c = that.map.getContainer();
//Check if have svg on map
var svg = map_c.querySelector('svg');
var _canvas = map_c.querySelector('canvas');
if(svg) {
var svg_attr = {
w: parseInt(svg.attributes.width.value),
h: parseInt(svg.attributes.height.value)
};
_canvas.width = svg_attr.w;
_canvas.height = svg_attr.h;
_canvas.style.display = 'block';
var serializer = new XMLSerializer();
var c = _canvas;
var ctx = c.getContext('2d');
ctx.clearRect(0, 0, svg_attr.w, svg_attr.h);
var trans_val = map_c.querySelector('.leaflet-map-pane').style['transform'].replace('translate','').replace(/px/g,'').replace('(','').replace(')','').split(',');
var trans_y = parseInt(trans_val[trans_val.length - 1]) ,
trans_x = parseInt(trans_val[trans_val.length - 2]);
ctx.translate(trans_x,trans_y);
ctx.drawSvg("<svg>"+serializer.serializeToString(svg)+"</svg>", 0, 0, svg_attr.w, svg_attr.h);
svg.style.display = 'none';
}
&#13;
@Transactional
public int getUserIdCreateIfNotExistent(String email) throws Exception {
try {
jdbcTemplate.queryForRowSet("SELECT pg_advisory_xact_lock(hashtext('users'), hashtext(?))", email);
return jdbcTemplate.queryForObject("SELECT id FROM users WHERE email = ?", Integer.class, email);
} catch (IncorrectResultSizeDataAccessException e) {
Thread.sleep(10000);
return jdbcTemplate.queryForObject("INSERT INTO users (email) values(?) RETURNING id", Integer.class, email);
}
}
&#13;