单击按钮使文字变大,代码如下,结果报错
<html>
<head>
<title></title><script language="javascript">
     function chan()
 {
    var mspan=document.getElementById("sp");
mspan.style.font-size="50px";
 }
</script>
</head>
<body>
<p>正点</p>
<span id="sp" style="font-size:9px; display:display;">hello</span>
<input type="button" value="变大"  onclick="chan();"/>
</body>
</html>

解决方案 »

  1.   

    mspan.style.font-size="50px";错了。改成 mspan.style.fontSize="50px";
      

  2.   

    <html>
    <head>
    <title></title><script language="javascript">
         function chan()
         {
            var mspan=document.getElementById("sp");
            mspan.style.fontSize="50px";
         }
    </script>
    </head>
    <body>
    <p>正点</p>
    <span id="sp" style="font-size:9px; display:display;">hello</span>
    <input type="button" value="变大"  onclick="chan();"/>
    </body>
    </html>
      

  3.   

    楼主,当在js里面引用style这个对象时,style下面出现符号“ - ”的,一律改为下一个单词首字母大写,和前面的单词拼接在一起。

    比如背景色:css: background-color:'blue';  
    js应用:  style.backgroundColor = 'blue';
    这样就 OK 了