其他設置不反應呢
?<!--當點擊相應按鈕,執行相應操作,為按鈕添加相應事件-->
? ? <input type="button" value="改變顏色" onclick="changeColor()" > ?
? ? <input type="button" value="改變寬高" onclick="changeWidth()">
? ? <input type="button" value="隱藏內容" onclick="hideText()">
? ? <input type="button" value="顯示內容" onclick="showText()">;
? ? <input type="button" value="取消設置" onclick=" cancle()">
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數
? ? function changeColor()
? ? {
? ? ? ? var mychar=document.getElementById("txt");
? ? ? ? mychar.style.color="red"; ? ?
? ? }
//定義"改變寬高"的函數
? ? function changeWidth()
? ? {
? ? ? ? var mychar=document.getElementById("txt");
? ? ? ? mychar.style.width=300px;?
? ? ? ? mychar.style.height=200px;
? ? }
//定義"隱藏內容"的函數
? ? function hideText()
? ? {
? ? ? ? var mychar = document.getElementById("txt");
? ? ? ? mychar.style.display="none";
? ? }
//定義"顯示內容"的函數
? ? function showText()
? ? {
? ? ? ? var mychar = document.getElementById("txt");
? ? ? ? mychar.style.display = "block";
? ? }
//定義"取消設置"的函數
? ? function cancle()
? ? {
? ? ? ? var message = confirm("確認取消全部設置?");
? ? ? ? if(message == true)
? ? ? ? {
? ? ? ? ? ? var mychar = document.getElementById("txt");
? ? ? ? ? ? mychar.removeAttribute("style");
? ? ? ? }
? ? ? ??
? ? } ? ?
幫忙看下為什么只有顏色設置點擊之后執行,其他的沒反應呢,謝謝!
2016-04-29
放在Dreamweaver里試了一下,除了樓上說的引號外,我刪了幾個function changeWidth()前的幾個空格就好了,好奇怪,
2016-04-29
function changeWidth()好像這個函數名有點問題
2016-04-28
200PX沒加“”,哈哈