1.<!DOCCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<select id="province">
<option value="-1">请选择</option>
</select>
<select id="city"></select>
<select id="country></select>"
<script>
var provinceArr=[‘上海‘,‘江苏‘,‘河北‘,‘湖南‘];
var cityArr=[[‘上海市‘],[‘南京市‘,‘苏州市‘,‘扬州市‘],[‘石家庄‘,‘秦皇岛‘,‘张家口‘],[‘湘潭‘]];
var countryyArr=[[[‘黄埔区‘,‘长宁区‘,‘浦东区‘],
[
[‘虎丘区‘,‘吴中区‘,‘吴江区‘],
[‘玄武区‘],[‘江都区‘]],
[
[‘长安区‘,‘桥西区‘,‘桥东区‘],[‘海港区‘],[‘下花园区‘]],[[‘石潭‘]]
]
];
function creationOption(obj,data{
for(var i in data){
var op=new Option(data[i],i);
obj.options.add(op);
}
}
var province=document.getElementById(‘province‘);
creationOption(province,provinceArr);
var city=document.getElementById(‘city‘);
province.onchange=function(){
city.options.length=0;
creationOption(city,cityArr[province.value]);
};
var country=document.getElementById(‘country‘);
province.onchange=function(){
country.options.length=0;
creationOption(country,countryArr[province.value][city.value]);
};
province.onchange=function(){
city.options.length=0;
creationOption(city,cityArr[province.value]);
if(province.value>=0){
city.onchange();
}else{
country.options.length=0;
}
};
</script>
</html>
2.<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
var arr = [1,2,3,4,2,5,6,2,7,2];
document.write("原数组:<br/>" + arr);
var a= arr.slice(3,4);
var b = arr.slice(0,1);
var c = arr.slice(2,3);
var d = arr.slice(5,6);
var e = arr.slice(6,7);
var f = arr.slice(8,9);
str = b.concat(c,a,d,e,f);
document.write("<br/>");
document.write("新数组:<br/>" + str);
document.write("<br/>");
document.write("原数组arr:<br/>" + arr);
</script>
</body>
</html>
3.<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style type="text/css">
div{
font-family: "Helvetica Neue",Helvetica,Arial,"Microsoft Yahei",sans-serif;
width: 600px;
text-align: center;
}
.haha{
margin-top: 20px;
margin-left: 250px;
font-size: 20px;
}
.haha:hover{
border: 3px solid purple;
}
</style>
</head>
<body>
<div id="joy">
<p>改变世界,改变自己</p>
</div>
<button class="haha" onclick="myFunction()">change</button>
<script type="text/javascript">
function myFunction(){
var Color = document.getElementById("joy");
Color.style.border = "3px double red";
Color.innerHTML = "<p>加油努力,坚持继续</p>";
}
</script>
</body>
</html>
4.我对于javascript还是很模糊,对于一些函数效果不了解,在编程的时候我查不出哪里出错了。
原文:https://www.cnblogs.com/qq1346941557/p/11673910.html