文字放大缩小

function sizeChange(){
if ($('.article-infor').length > 0) {
$(".article-infor").each(function () {
var $this = $(this),
// $this_p = $this;
$this_p = $this.find('.allZoom'); //需要所包含的所有内容都可放大缩小
if ($this_p.length > 0) {
var fsize = $this_p.css("font-size"),
textsize = parseInt(fsize, 10),
px = fsize.slice(-2);
$this.on('click', '.article_opt .zoom', function () {
var type = $(this).attr("data-type"),
new_textsize = type == "zoom_in" ? textsize + 2 : textsize - 2;
if (new_textsize <= 20 && new_textsize >= 10) {
textsize = new_textsize;
$this_p.css("font-size", textsize + px);
$this_p.find('*').css('font-size', textsize + px);
//需要所包含的所有内容(如表格内容等)都可放大缩小
}
});
}
});
}
}
$(".zoom").click(function(){
sizeChange();
})
<div class="article-infor">
<h2>上交所就*ST博元股票终止上市答记者问</h2>
<div class="article_opt">
<span>
<a href="javascript:window.print();" class="mobile_hide sseicon-icon_print"></a>
<a href="javascript:;" class="zoom sseicon-icon_fontSizeUp" data-type="zoom_in"></a>
<a href="javascript:;" class="zoom sseicon-icon_fontSizeDown" data-type="zoom_out"></a>
</span>
<i> 2016-03-21</i>
</div>
<div class="allZoom">
<p>上交所就*ST博元股票终止上市答记者问</p>

</div>

</div>
原文地址:https://www.cnblogs.com/ylsq/p/5318714.html