Note: The CSS style in JavaScript differs from the styles in non-JavaScript, in non-JavaScript style font size: Font-size, and in JavaScript it is fontsize.
In a style other than JavaScript, "-" is rewritten with the second letter capitalized
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title></title>
<style type= "Text/css" >
. Re {
Background-color:gray;
font-weight:200;
padding:30px;
}
</style>
<script type= "Text/javascript" >
Window.onload = function () {
var btnbig = document.getElementById (' big ');
var btnlit = document.getElementById (' litter ');
var btnstyle = document.getElementById (' Btnstyle ');
var p1 = document.getElementById (' pnew ');
var FZ = 12;
Amplification
Btnbig.onclick = function () {
fz++;
P1.style.fontSize = fz+ "px";
}
Narrow
Btnlit.onclick = function () {
if (FZ > 0) {
fz--;
P1.style.fontSize = FZ + "px";
}
else {
Alert ("No more small!" ");
}
}
Set format
Btnstyle.onclick = function () {
P1.classname = ' re ';
}
}
</script>
<body>
<input type= "button" id= "Big" value= "grow"/>
<input type= "button" id= "litter" value= "Zoom Out"/>
<input type= "button" id= "Btnstyle" value= "set style"/>
<p id= "Pnew" >
He said that in the past three weeks, the police have dealt with the illegal behaviour of demonstrators in an extremely tolerant manner,
The aim is to hope that the people concerned can calm down and
To express their demands in a peaceful, rational and lawful manner. It is a pity that they are still unchanged,
Even worse. These illegal acts are constantly hurting Hong Kong, making it impossible for school to go to school, to work normally,
Business can not be normal business, sick people can not normal visits, all walks of life are very serious impact.
</p>
</body>
This article is from the "Day to Up" blog, so be sure to keep this source http://1433189426.blog.51cto.com/8055494/1565730
JavaScript Learning-the enlargement and reduction of paragraph font