請幫我看下哪里錯(cuò)了
function size(){
var si=document.getElementById("txt");
si.style.width="500px";
si.style.height="500px";}
改變寬高是這么寫的,但為啥點(diǎn)擊按鈕沒反應(yīng)
function size(){
var si=document.getElementById("txt");
si.style.width="500px";
si.style.height="500px";}
改變寬高是這么寫的,但為啥點(diǎn)擊按鈕沒反應(yīng)
2016-03-21
舉報(bào)
2016-03-21
我試了試你的代碼,發(fā)現(xiàn)把函數(shù)名size()改成別的就行了,我給改成了csize(),我也不知道為什么,但是改了之后確實(shí)就可以了。
2016-03-21
size是保留字
2016-03-21
我也是新手,你這個(gè)函數(shù)size后面加個(gè)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為網(wǎng)頁添加動態(tài)效果并實(shí)現(xiàn)與用戶交互的功能。</h5>
? ? ? ? <p>1. JavaScript入門</p>
? ? ? ? <p>2. JavaScript進(jìn)階</p>
? ? ? ? <p>3. 學(xué)完以上兩門c</p>
? </div>
? <form>
??
? ? <input type="button" value="改變顏色" onClick="color()"> ?
? ? <input type="button" value="改變寬高" onClick="size()">
? ? <input type="button" value="隱藏內(nèi)容" onClick="hide()">
? ? <input type="button" value="顯示內(nèi)容" onClick="show()">
? ? <input type="button" value="取消設(shè)置" 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函數(shù)沒寫錯(cuò)吧?,高寬數(shù)字改差異大一點(diǎn)看的明顯
2016-03-21
oclick函數(shù)沒寫錯(cuò)吧?
2016-03-21
你onclick事件寫了嗎?