本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《
阿里云开发者社区用户服务协议
》和
《
阿里云开发者社区知识产权保护指引
》。如果您发现本社区中有涉嫌抄袭的内容,填写
侵权投诉表单
进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
$(
"
span
"
).click(function(){
//
获取para的字体大小
var
thisEle = $(
"
#para
"
).css(
"
font-size
"
);
//
parseFloat的第二个参数表示转化的进制,10就表示转为10进制
var
textFontSize = parseFloat(thisEle ,
10
);
//
javascript自带方法
var
unit = thisEle.slice(-
2
);
//
获取单位
var
cName = $(
this
).attr(
"
class
"
);
if
(cName ==
"
bigger
"
){
textFontSize
+=
2
;
}
else
if
(cName ==
"
smaller
"
){
textFontSize
-=
2
;
//
设置para的字体大小
$(
"
#para
"
).css(
"
font-size
"
, textFontSize +
unit );
</script>
<div
class
=
"
msg_caption
"
>
<span
class
=
"
bigger
"
>放大</span>
<span
class
=
"
smaller
"
>缩小</span>
<p id=
"
para
"
>
This
is
some text. This
is
some text. This
is
some text. This
is
some text. This
is
some text. This
is
some text. This
is
some text. This
is
some text. This
is
some
text. This
is
some text. This
is
some text. This
is
some text. This
is
some text.
This
is
some text. This
is
some text. This
is
some text. This
is
some text. This
is
some text. This
is
some text.
</body>