我试图使jQuery用户界面斯利德作为滑块选择‘字体大小’。我不知道我的语法在哪里,但它不起作用。文字输入中的数字正在改变,但文字大小不.
HTML:
<div id="slider"></div>
<input type="text" id="font_size" style="border:0; color:#222; font-weight:bold;" />
<div class="textBox">Lorem ipsum dolor sit amet, id quaestio percipitur vel. Zril propriae vis in, an mei commune invidunt. Nam et nibh consul, vim ei facer nonumes principes. Nec te facilis noluisse. Utinam doming perfecto eum id, mea at patrioque liberavisse, at sit abhorreant referrentur.</div>jQuery:
$(function() {
var aFontsSizeArray = new Array('5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '24', '26', '28', '30', '33', '36', '39', '42', '45', '48', '55', '65', '75', '85', '95', '110', '130', '150');
$('#slider').slider({
value: 7,
min: 1,
max: 35,
step: 1,
slide: function(event, ui) {
var sFontSizeArray = aFontsSizeArray[ui.value];
$('#font_size').val(sFontSizeArray + ' px');
$('.textBox').css('font-size', sFontSizeArray );
}
});
$('#font_size').val((aFontsSizeArray[$('#slider').slider('value')]) + ' px');
});发布于 2012-10-07 14:22:15
您忘记在代码中添加+ 'px':
$('.textBox').css('font-size', sFontSizeArray + 'px' );https://stackoverflow.com/questions/12769605
复制相似问题