我在我的html中有2個div,我想通過onclick增加大小,但fontSize不會更改。最大化一個div並更改其字體大小
代碼:
function changeSize(id, weight, height)
{
with (document)
{
\t if (getElementById(id).style.width = '240px'){
\t \t getElementById(id).style.width = weight + 'px';
\t \t getElementById(id).style.height = height + 'px';
\t \t getElementById(id).style.fontSize = '30px';
\t } \t
\t else {
\t \t getElementById(id).style.width ='240px';
\t \t getElementById(id).style.height ='300px';
\t \t getElementById(id).style.fontSize = '18px';
\t }
}
}
.kaesten{
\t width:240px;
\t height:300px;
\t background-color:darkgrey;
\t background-position:center;
\t background-repeat:no-repeat;
\t text-shadow:0px 0px 3px #000;
\t border: 5px solid #F0F8ff;
\t vertical-align:top;
\t text-shadow: 3px 3px 4px #777;
\t float:left;
\t margin-left:30px;
}
<div id="box1" class="kaesten" onclick="maxi('box1', 600, 600); return false;">
test1
</div>
<div id="box2" class="kaesten">
test2
</div>
問:我怎樣才能改變fontSize的?如何通過第二次點擊將div大小再次改變爲原始大小?
嘗試'getElementByID(id).style.fontSize ='30px';' – KittMedia
它不起作用! – nolags
try getElementById(id).style.fontSize ='30'+'px'; – akash