//定义"取消设置"的函数
function cancel(){
if(confirm("是否取消设置?")){
document.getElementById("txt").removeAttribute('style');
}
}
因为在写函数的时候多写了一个},导致整个函数都用不了,找了半天才发现....
function cancel(){
if(confirm("是否取消设置?")){
document.getElementById("txt").removeAttribute('style');
}
}
因为在写函数的时候多写了一个},导致整个函数都用不了,找了半天才发现....
mychar.style.color="red";
mychar.style.backgroundColor="#CCC";
mychar.style.width="300px";
mychar.style.backgroundColor="#CCC";
mychar.style.width="300px";
2015-05-20
已采纳回答 / Perona
第10行:document.write(mtstr+mychar+"的忠实粉丝");这里变量名写错了,前面定义的变量名是mystr,这里变成mtstr,改过来了就好。<...code...>
2015-05-20
<form>
<input type="button" onClick = "showHint(setColor)" value="改变颜色" >
...
...
<input type="button" onclick="showHint(cancel)" value="取消设置" >
</form>
function showHint(fun)
{
var hint = confirm("确定要这样做吗?");
if(hint)
{
fun();
}
}
<input type="button" onClick = "showHint(setColor)" value="改变颜色" >
...
...
<input type="button" onclick="showHint(cancel)" value="取消设置" >
</form>
function showHint(fun)
{
var hint = confirm("确定要这样做吗?");
if(hint)
{
fun();
}
}