jquery放大缩小文字

$(function(){

$("span").click(function(){

var theSize = $("#title").css("font-size");

var theTitleSize =parseFloat(theSize,10);//获取字体的大小

var units = theSize.slice(-2); //获取单位

var c_name = $(this).attr("class");//获取属性

if(c_name =="c_big"){//如果是放大则增大文字

if(theTitleSize <= 22){//判断大小,如果小于22px则减少

theTitleSize+=2;

}

}else if(c_name =="c_small"){//如果是缩小则缩小文字

if(theTitleSize >= 12){//判断大小,如果大于12px则减少

theTitleSize-=2;

}

}

$("#title").css("font-size",theTitleSize + units);//添加样式

});

});

#content{

width:300px;

height:450px;

background:#000000;

}

.c_big{

width:30px;

height:15px;

background:#00F;

border:1px;

margin:20px 20px;

}

.c_small{

width:30px;

height:15px;

background:#00F;

border:1px;

margin:10px 20px;

}

#title{

color:#FFFFFF;

}

放大缩小

举得起放得下的叫举重,举得起放不下的叫负重。可惜,大多数人的爱情,都是负重的。

If you can hold something up and put it down, it is called weight-lifting; if you can hold something up but can never put it down,it's called burden-bearing. Pitifully, most of people are bearing heavy burdens when they are in love.

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐