在这里的jsfiddle http://jsfiddle.net/stevea/gQqLs/7/中,我想在每次选择按钮时突破div的行高,以及增加填充的方式:
$('#box1') .css('padding-top', "+=5" ); // works
// $('#box1') .css('line-height', "+=5" ); // does not work
你可以在jsfiddle中看到我试图强行通过,但即使在第10行,我还没有完成,因为看起来lineHeight仍然需要回到字符串才能工作。必须有更好的方法来做到这一点。感谢您的任何建议。
答案 0 :(得分:2)
对我来说,以下作品(http://jsfiddle.net/stas_sl/LkueJ/3/):
$(function(){
$('#bump').click(function() {
newLineHeight = parseInt($('#box1').css('line-height'))+5+'px';
$('#box1') .css('padding-top', "+=5" );
$('#box1') .css('line-height', newLineHeight);
});
});