請幫我看下哪里錯了
function size(){
var si=document.getElementById("txt");
si.style.width="500px";
si.style.height="500px";}
改變寬高是這么寫的,但為啥點擊按鈕沒反應
function size(){
var si=document.getElementById("txt");
si.style.width="500px";
si.style.height="500px";}
改變寬高是這么寫的,但為啥點擊按鈕沒反應
2016-03-21
舉報
2016-03-21
我試了試你的代碼,發現把函數名size()改成別的就行了,我給改成了csize(),我也不知道為什么,但是改了之后確實就可以了。
2016-03-21
size是保留字
2016-03-21
我也是新手,你這個函數size后面加個text好像就能用了
2016-03-21
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" Content="text/html; charset=utf-8" />
<title>javascript</title>
<style type="text/css">
body{font-size:12px;}
#txt{
? ? height:400px;
? ? width:600px;
border:#333 solid 1px;
padding:5px;}
p{
line-height:18px;
text-indent:2em;}
</style>
</head>
<body>
? <h2 id="con">JavaScript課程</H2>
? <div id="txt">?
? ? ?<h5>JavaScript為網頁添加動態效果并實現與用戶交互的功能。</h5>
? ? ? ? <p>1. JavaScript入門</p>
? ? ? ? <p>2. JavaScript進階</p>
? ? ? ? <p>3. 學完以上兩門c</p>
? </div>
? <form>
??
? ? <input type="button" value="改變顏色" onClick="color()"> ?
? ? <input type="button" value="改變寬高" onClick="size()">
? ? <input type="button" value="隱藏內容" onClick="hide()">
? ? <input type="button" value="顯示內容" onClick="show()">
? ? <input type="button" value="取消設置" onClick="reset()">
? </form>
? <script type="text/javascript">
function color(){var co=document.getElementById("txt");co.style.color="red";}
function size(){var si=document.getElementById("txt");si.style.width="500px";si.style.height="500px";}
function hide(){var hi=document.getElementById("txt");hi.style.display="none";}
function show(){var sh=document.getElementById("txt");sh.style.display="block";}
function reset(){
? ? var a=confirm("reset?");
? ? if(a==true)
? ? {}
? ? }
? </script>
</body>
</html>
2016-03-21
onclick函數沒寫錯吧?,高寬數字改差異大一點看的明顯
2016-03-21
oclick函數沒寫錯吧?
2016-03-21
你onclick事件寫了嗎?