為什么運行不了呢?
? <script type="text/javascript">
var mychar=document.getElementById("txt");
? ? function changeColor(){
? ? ? ? mychar.style.color="red";
? ? ? ? mychar.style.backgroundColor="blue";
? ? }
? ? function changeSize(){
? ? ? ? mychar.style.width="200px";
? ? ? ? mychar.style.height="300px";
? ? }
? ? function hidetext(){
? ? ? ? mychar.style.display="none";
? ? }
? ? function showtext(){
? ? ? ? mychar.style.display="block";
? ? }
? ? function resttext(){
? ? ? ? var message = confirm("你確定要重置所有設置么?");
? ? ? ? if(message==true){
? ? ? ? ? ? mychar.removeAttribute("style");
? ? ? ? }
? ? }
</script>
2016-04-22
var message = confirm("你確定要重置所有設置么?");分號錯誤應為英文狀態的 ' ; '
2016-04-22
你在input里面是否調用了各個函數,我瞅了瞅你的代碼沒什么錯誤 ,你自己找找有沒有不是英文符號的,是中文的
2016-04-22
?<!--當點擊相應按鈕,執行相應操作,為按鈕添加相應事件-->
? ? <input type="button" value="改變顏色" onclike="test1()" /> ?
? ? <input type="button" value="改變寬高" onclick="test2()" />
? ? <input type="button" value="隱藏內容" onclick="test3()" />
? ? <input type="button" value="顯示內容" onclick="test4()" />
? ? <input type="button" value="取消設置" onclick="test5()" />
? </form>
? <script type="text/javascript">
//定義"改變顏色"的函數
var a=getElementById("txt");
function test1()
{a.style.color="red";
a.style.background="blue";
? ??
}
//定義"改變寬高"的函數
function test2()
{a.style.width="700px";
a.style.height="300px";
? ??
}
//定義"隱藏內容"的函數
function test3(){
? ? a.style.display="none";
? ??
}
//定義"顯示內容"的函數
function test4(){
a.style.display="block";
}
//定義"取消設置"的函數
function test5(){
? ? var reset = confirm("是否取消設置?");
? ? if(reset=true){
? ? ? ? mychar.removeAttribute("style");
? ? ? ??
? </script>
我這個也運行不了 不知道什么問題
2016-04-21
<form>
??? <input type="button" value="改變顏色" onclick="changeColor()"> ?
??? <input type="button" value="改變寬高" onclick="changeSize()">
??? <input type="button" value="隱藏內容" onclick="hidetext()">
??? <input type="button" value="顯示內容" onclick="showtext()">
??? <input type="button" value="取消設置" onclick="resttext()">
? </form>
2016-04-21
button點擊事件添加了沒有,看不到回答個毛