//文字放大缩小默认

<span id="view"><a href="#" class="bigger">放大</a><a href="#" class="smaller">缩小</a><a href="#" class="def">默认</a></span>


js:

//文字放大缩小默认

$(function(){ 

$("#view a").click(function(){ 

var thisEle = $("#para").css("font-size"); 

var textFontSize = parseFloat(thisEle , 10); 

var unit = thisEle.slice(-2); //获取单位 

var cName = $(this).attr("class"); 

if(cName == "bigger"){ 

if( textFontSize <= 22 ){ 

textFontSize += 2; 

}else if(cName == "smaller"){ 

//if( textFontSize >= 12 ){ 

textFontSize -= 2; 

//} 

}else if(cName == "def"){

textFontSize = 14; //font-size:14px;

}

$("#para").css("font-size", textFontSize + unit); 

}); 

});


你可能感兴趣的:(//文字放大缩小默认)