赋值主要是两种,一种是字符串,一种是数值,字符串可以理解为文本类型的,数值就是数值,字符串需要用“”,而数值不用。例如var mynum=69 和var mynum="69"就是不一样的,虽然最后的显示效果是一样的,但是实际上是不同的。
2016-08-18
<script type="text/javascript">
function contxt() //定义函数
{
alert("哈哈,调用函数了!");
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我" onclick=" contxt() " />
function contxt() //定义函数
{
alert("哈哈,调用函数了!");
}
</script>
</head>
<body>
<form>
<input type="button" value="点击我" onclick=" contxt() " />
2016-08-18
<script type="text/javascript">
var score =80; //score变量存储成绩,初值为80
if(score>=60){
document.write("恭喜你,你及格了");
}
else{
document.write("很稀罕,继续努力!");
}
</script>
var score =80; //score变量存储成绩,初值为80
if(score>=60){
document.write("恭喜你,你及格了");
}
else{
document.write("很稀罕,继续努力!");
}
</script>
2016-08-18
<input type="button" value="改变颜色" onclick="changecolor()">
<input type="button" value="改变宽高" onclick="changeheight()">
<input type="button" value="隐藏内容" onclick="hidden()">
<input type="button" value="显示内容" onclick="unhidden()">
<input type="button" value="取消设置" onclick="unall()">
<input type="button" value="改变宽高" onclick="changeheight()">
<input type="button" value="隐藏内容" onclick="hidden()">
<input type="button" value="显示内容" onclick="unhidden()">
<input type="button" value="取消设置" onclick="unall()">
function changecolor()
{
var txt1=document.getElementById("txt");
txt1.style.color="red";
txt1.style.backgroundColor="blue";
}
{
var txt1=document.getElementById("txt");
txt1.style.color="red";
txt1.style.backgroundColor="blue";
}
//定义"改变宽高"的函数
function changeheight()
{
var txt2=document.getElementById("txt");
txt2.style.width="500px";
txt2.style.height="700px";
}
//定义"隐藏内容"的函数
function hidden()
{
var txt3=document.getElementById("txt");
txt3.style.display="none";
}
function changeheight()
{
var txt2=document.getElementById("txt");
txt2.style.width="500px";
txt2.style.height="700px";
}
//定义"隐藏内容"的函数
function hidden()
{
var txt3=document.getElementById("txt");
txt3.style.display="none";
}
//定义"显示内容"的函数
function unhidden()
{
var txt4=document.getElementById("txt");
txt4.style.display="block";
}
//定义"取消设置"的函数
function unall()
{
var txt5=document.getElementById("txt");
txt5.setAttribute('style','');
}
function unhidden()
{
var txt4=document.getElementById("txt");
txt4.style.display="block";
}
//定义"取消设置"的函数
function unall()
{
var txt5=document.getElementById("txt");
txt5.setAttribute('style','');
}
var mychar= document.getElementById("con");
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello world";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
document.write("原标题:"+mychar.innerHTML+"<br>"); //输出原h2标签内容
mychar.innerHTML="Hello world";
document.write("修改后的标题:"+mychar.innerHTML); //输出修改后h2标签内容
</script>
2016-08-17
已采纳回答 / 慕粉3803372
confirm("确定打开新窗口吗?") confirm元素使用时出现一个窗口选择确定和取消,选择‘确定’自动赋予confirm返回值为true,选‘取消’则返回值为false,if()中如果没有限定条件,如confirm=true或者confirm=false,默认的判断条件是if(t),参数t是否为真
2016-08-17
我发现其实大部分的错误集中在各种字母打错以及标点上,列如,";"这是英文符号,“;”这是中文的,中文的不能用的