都不出來~~~好難過呀~~哪的問題呀
<!DOCTYPE HTML>
<html>
??? <head>
??????? <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
??????? <title>無標題文檔</title>
??? </head>
???
??? <body>
??????? <form>
????????? 請選擇你愛好:<br>
????????? <input type="checkbox" name="hobby" id="hobby1">? 音樂
????????? <input type="checkbox" name="hobby" id="hobby2">? 登山
????????? <input type="checkbox" name="hobby" id="hobby3">? 游泳
????????? <input type="checkbox" name="hobby" id="hobby4">? 閱讀
????????? <input type="checkbox" name="hobby" id="hobby5">? 打球
????????? <input type="checkbox" name="hobby" id="hobby6">? 跑步 <br>
????????? <input type="button" value = "全選" onclick = "checkall();">
????????? <input type="button" value = "全不選" onclick = "clearall();">
????????? <p>請輸入您要選擇愛好的序號,序號為1-6:</p>
????????? <input id="wb" name="wb" type="text" >
????????? <input name="ok" type="button" value="確定" onclick = "checkone();">
??????? </form>
??????? <script type="text/javascript">
???????? function checkall(){
??????????? var hobby = document.getElementsByTagName("input");
??????????? for(var i=0;i<hobby.length;i++){
??????????????????? if(hobby[i].type=="checkbox"){
??????????????????? hobby[i].checked=true;??
??????????????????? }??????????????
??????????????? }
??????????? }
??????? function clearall(){
??????????? var hobby = document.getElementsByName("hobby");
???????????
???????? // 任務(wù)2???
???????? for(var i=0;i<hobby.length;i++){
???????????? hobby[i].checked=false;
???????? }
???????????
??????? }
???????
??????? function checkone(){
??????????? var j=document.getElementById("wb").value;
???????
???????? // 任務(wù)3
???????? if(j>0&&j<=6)
???????? document.getElementById("hobby"+j).checked=true;
??????? }
??????? else alert("請輸入1-6的值");
???????
??????? </script>
??? </body>
</html>
2018-09-27
上面的是我寫的? ,
下面這段是我給你改完bug的? 你有些符號比如括號沒寫全
<!-- <!DOCTYPE html>
<html>
<meta charset="UTF-8">
<head></head>
<body>
<form id="form2">
<input type="checkbox" name="test1" value="1"/><span>1</span>
<input type="checkbox" name="test1" value="2"/><span>2</span>
<input type="checkbox" name="test1" value="3"/><span>3</span>
<input type="checkbox" name="test1" value="4"/><span>4</span>
<input type="checkbox" name="test1" value="5"/><span>5</span>
<input type='button' value='提交' onclick="show()"/>
<span>haha</span>
</form>
<script type="text/javascript">
var show? = function(){
setTimeout("alert(111)",3000)
}
show();
var obj = document.querySelectorAll("input[name]");
console.log(obj);
</script>
</body>
</html> -->
<!-- <!Doctype html>
<html>
<meta charset="UTF-8">
? ? <body>
? ? ? ? <span id="js_onclick">點擊</span>
? ? ? ? <span id="js_onmouseover">鼠標經(jīng)過</span>
? ? ? ? <span id="js_onmouseout">鼠標移開</span>
? ? ? ? <span id="js_onchange">文本框內(nèi)容改變</span>
? ? ? ? <span id="js_onfocus">光標聚焦</span>
? ? </body>
? ??
? ? <script type="text/javascript">
? ? ? ? var js_onclick = document.getElementById("js_onclick");
? ? ? ? var js_onmouseover = document.getElementById("js_onmouseover");
? ? ? ? var js_onmouseout = document.getElementById("js_onmouseout");
? ? ? ? var js_onchange = document.getElementById("js_onchange");
? ? ? ? var js_onfocus = document.getElementById("js_onfocus");
? ? ? ? js_onclick.onclick = function(){
alert('點擊');
};
js_onmouseover.onmouseover = function(){
alert('鼠標經(jīng)過');
}
js_onmouseout.onmouseout = function(){
alert('鼠標移開');
}
js_onfocus.onfocus = function(){
alert('光標聚焦');
}
? ? </script>
</html> -->
<!-- <!DOCTYPE html>
<html>
?<head>
? <title> 事件</title>??
? <meta charset="UTF-8">
?</head>?
?<body>
? ?<input type='text' id='txt1' />?
? ?<select id='select'>
<option value='+'>+</option>
<option value="-">-</option>
<option value="*">*</option>
<option value="/">/</option>
? ?</select>
? ?<input type='text' id='txt2' />?
? ?<input type='button' value=' = ' onclick="count();" />?
? ?<input type='text' id='fruit' />? ?
?</body>
? <script type="text/javascript">
? ?function count(){
? ? ? ?
? ? //獲取第一個輸入框的值
? ? var txt1 = document.getElementById('txt1').value;
? ? var txt2 = document.getElementById('txt2').value;
//獲取第二個輸入框的值
//獲取選擇框的值
var select = document.getElementById("select");
var index = select.selectedIndex;
var select_val = select.options[index].value
alert(txt1);
//獲取通過下拉框來選擇的值來改變加減乘除的運算法則
? ? //設(shè)置結(jié)果輸入框的值?
? ??
? ?}
? </script>??
</html> -->
<!-- <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計時器</title>
<script type="text/javascript">
var interval;
? ? function clock1(){? ? ??
? ? interval = setInterval(function(){
var time=new Date();
document.getElementById("clock").value = time; ??
? },1000);
? ? }
? ?
</script>
</head>
<body? onload="clock1()" >
? <form>
? ? <input type="text" id="clock" size="50"? />
? ? ?<input type="button" value="start" onclick="clock1()" />? ?
? ? <input type="button" value="Stop" onclick="clearInterval(interval)" />
? </form>
</body>
</html> -->
<!-- <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>計時器</title>
<script type="text/javascript">
? var num=0;
? var i;
? function startCount(){
? ? document.getElementById('count').value=num;
? ? num=num+1;
? ? i=setTimeout("startCount()",1000);
? }
? function stopCount(){
? ? clearTimeout(i);
? }
</script>
</head>
<body>
? <form>
? ? <input type="text" id="count" />
? ? <input type="button" value="Start"? onclick="startCount()"/>
? ? <input type="button" value="Stop" onclick="stopCount()"? ?/>
? </form>
</body>
</html> -->
<!-- <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無標題文檔</title>
<script type="text/javascript">
? ? ? ? function GoBack() {
? ? ? ? ? ? window.history.back(-1);
? ? ? ? }
? ? ? ?
</script>
</head>
?
<body>
點擊下面的錨點鏈接,添加歷史列表項:
? ??
? ? <br />
? ? <a href="#target1">第一個錨點</a>
? ? <a name="target1"></a>
? ? <br />
? ? <a href="#target2">第二個錨點</a>
? ? <a name="target2"></a>
? ? <br /><br />
? ? 使用下面按鈕,實現(xiàn)返回前一個頁面:
? ? <form>
? ? ? ?<input type="button"? value="返回前一個頁面" onclick="GoBack();" />? ? ? ??
? ? </form>
</body>
</html> -->
<!-- <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>無標題文檔</title>
<script type="text/javascript">
? ? ? ? function GoForward() {
? ? ? ? ? ? window.history.forward();
? ? ? ? }
</script>
</head>
?
<body>
點擊下面的錨點鏈接,添加歷史列表項:? ??
? ? <br />
? ? <a href="#target1">第一個錨點</a>
? ? <a name="target1"></a>
? ? <br />
? ? <a href="#target2">第二個錨點</a>
? ? <a name="target2"></a>
? ? <br /><br />
? ? 使用下面按鈕,實現(xiàn)返回下一個頁面:
? ? <form>
? ? ? ?<input type="button"? value="返回下一個頁面" onclick="GoForward()" />? ? ? ??
? ? </form>
</body>
</html> -->
<!-- <!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>navigator</title>
<script type="text/javascript">
? function validB(){?
? ? var u_agent = navigator.userAgent;
? ? var B_name="不是想用的主流瀏覽器!";?
? ? if(u_agent.indexOf("Firefox")>-1){?
? ? ? ? B_name="Firefox";?
? ? }else if(u_agent.indexOf("Chrome")>-1){?
? ? ? ? B_name="Chrome";?
? ? }else if(u_agent.indexOf("MSIE")>-1&&u_agent.indexOf("Trident")>-1){?
? ? ? ? B_name="IE(8-10)";??
? ? }
? ? ? ? document.write("瀏覽器:"+B_name+"<br>");
? ? ? ? document.write("u_agent:"+u_agent+"<br>");?
? }?
</script>
</head>
<body>
? <form>
? ? ?<input type="button" value="查看瀏覽器" onclick="validB()"? >
? </form>
</body>
</html> -->
<!-- <!DOCTYPE html>
<html>
?<head>
? <title>瀏覽器對象</title>??
? <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>? ?
?</head>
?<body>??
?<span id="time">5</span>秒后返回主頁<a target="_blank">返回</a>
?
? <script type="text/javascript">??
? ? var start = 5;
? ? var time = document.getElementById("time");
? ? setInterval(function(){
? ? ? ? time.innerHTML = start-1;
start--;
if(start<1){
window.location.;
}
? ? },1000);
?</script>?
</body>
</html> -->
<!-- <!DOCTYPE HTML>
<html>??
<head>??
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />??
<title>JavaScript</title>??
</head>??
<body>??
? ??
? ? ? ? <form name="Input">
? ? ? ? ? ? <table align="center" width="500px" height="50%" border="1">
? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? <td align="center" width="100px">
? ? ? ? ? ? ? ? ? ? ? ? 學號:
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? <td align="center" width="300px">
? ? ? ? ? ? ? ? ? ? ? ? <input type="text" id=userid name="user" onblur="validate();">
? ? ? ? ? ? ? ? ? ? ? ? <div id=usermsg></div>
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? <td align="center" width="100px">
? ? ? ? ? ? ? ? ? ? ? ? 姓名:
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? ? ? <td align="center">
? ? ? ? ? ? ? ? ? ? ? ? <input type="text" name="name">
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? <td align="center" width="%45">
? ? ? ? ? ? ? ? ? ? ? ? 性別:
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? <td align="center">
? ? ? ? ? ? ? ? ? ? ? ? <input type="radio" name="sex" value="男">
? ? ? ? ? ? ? ? ? ? ? ? 男
? ? ? ? ? ? ? ? ? ? ? ? <input type="radio" name="sex" value="女">
? ? ? ? ? ? ? ? ? ? ? ? 女
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? <td align="center" width="30%">
? ? ? ? ? ? ? ? ? ? ? ? 年齡:
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? <td align="center" width="300px">
? ? ? ? ? ? ? ? ? ? ? ? <input type="text" name="age">
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? ? ? <tr>
? ? ? ? ? ? ? ? ? ? <td align="center" width="100px">
? ? ? ? ? ? ? ? ? ? ? ? 地址:
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? ? ? <td align="center" width="300px">
? ? ? ? ? ? ? ? ? ? ? ? <input type="text" name="addr">
? ? ? ? ? ? ? ? ? ? </td>
? ? ? ? ? ? ? ? </tr>
? ? ? ? ? ? </table>
? ? ? ? </form>
? ? ? ? <h1 id="myHead" onclick="getValue()">
? ? ? ? ? ? 看看三種獲取節(jié)點的方法?
? ? ? ? </h1>
? ? ? ? <p>
? ? ? ? ? ? 點擊標題彈出它的值。
? ? ? ? </p>
? ? ? ? <input type="button" onclick="getElements()"
? ? ? ? ? ? value="看看name為sex的節(jié)點有幾個?" />
? ? ? ? <Br>
? ? ? ? <input type="button" onclick="getTagElements()"
? ? ? ? ? ? value="看看標簽名為input的節(jié)點有幾個?" />
? ? ? ? ? ??
? ? ?<script type="text/javascript">
? ? ? ? ?function getValue()
? ? ? ? ? {
? ? ? ? ? ? ? var myH = document.getElementById("myHead");
? ? ? ? ? ? ? alert(myH.innerHTML)
? ? ? ? ? }
? ? ? ? ? function getElements()
? ? ? ? ? {
? ? ? ? ? ? ?var myS = document.getElementsByName("sex");
? ? ? ? ? ? ? alert(myS.length);
? ? ? ? ? }
? ? ? ? ? function getTagElements()
? ? ? ? ? {
? ? ? ? ? ? ? var myI = document.getElementsByTagName("input");
? ? ? ? ? ? ? alert(myI.length);
? ? ? ? ? }
? ? ? ? ?
? ? ?</script>? ? ? ??
? ? </body>
</html> -->
<!-- <!DOCTYPE HTML>
<html>
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ? ? ? <title>無標題文檔</title>
? ? </head>
? ??
? ? <body>
? ? ? ? <form>
? ? ? ? ? 請選擇你愛好:<br>
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby1">? 音樂
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby2">? 登山
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby3">? 游泳
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby4">? 閱讀
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby5">? 打球
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby6">? 跑步 <br>
? ? ? ? ? <input type="button" value = "全選" onclick = "checkall();">
? ? ? ? ? <input type="button" value = "全不選" onclick = "clearall();">
? ? ? ? ? <p>請輸入您要選擇愛好的序號,序號為1-6:</p>
? ? ? ? ? <input id="wb" name="wb" type="text" >
? ? ? ? ? <input name="ok" type="button" value="確定" onclick = "checkone();">
? ? ? ? </form>
? ? ? ? <script type="text/javascript">
? ? ? ? function checkall(){
? ? ? ? ? ? var hobby = document.getElementsByTagName("input");
? ? ? ? ? ? for(key in hobby)
? ? ? ? ? ?hobby[key].checked = true
? ? ? ? ? // 任務(wù)1?
? ? ? ? ? ?
? ? ? ? }
? ? ? ? function clearall(){
? ? ? ? ? ? var hobby = document.getElementsByName("hobby");
? ? ? ? ? ? ? ? ? ? ? ? for(key in hobby)
? ? ? ? ? ?hobby[key].checked = false
? ? ? ? ? ??
? ? ? ? ?// 任務(wù)2? ??
? ? ? ? ? ??
? ? ? ? }
? ? ? ??
? ? ? ? function checkone(){
? ? ? ? ? ? var j=document.getElementById("wb").value;
? ? ? ? var hobby = document.getElementsByTagName("input");
? ? ? ??
? ? ? ? hobby[j-1].checked = true;
? ? ? ? ?// 任務(wù)3
? ? ? ??
? ? ? ? }
? ? ? ??
? ? ? ? </script>
? ? </body>
</html> -->
<!DOCTYPE HTML>
<html>
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ? ? ? <title>無標題文檔</title>
? ? </head>
? ??
? ? <body>
? ? ? ? <form>
? ? ? ? ? 請選擇你愛好:<br>
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby1">? 音樂
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby2">? 登山
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby3">? 游泳
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby4">? 閱讀
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby5">? 打球
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby6">? 跑步 <br>
? ? ? ? ? <input type="button" value = "全選" onclick = "checkall();">
? ? ? ? ? <input type="button" value = "全不選" onclick = "clearall();">
? ? ? ? ? <p>請輸入您要選擇愛好的序號,序號為1-6:</p>
? ? ? ? ? <input id="wb" name="wb" type="text" >
? ? ? ? ? <input name="ok" type="button" value="確定" onclick = "checkone();">
? ? ? ? </form>
? ? ? ? <script type="text/javascript">
? ? ? ? ?function checkall(){
? ? ? ? ? ? var hobby = document.getElementsByTagName("input");
? ? ? ? ? ? for(var i=0;i<hobby.length;i++){
? ? ? ? ? ? ? ? ? ? if(hobby[i].type=="checkbox"){
? ? ? ? ? ? ? ? ? ? hobby[i].checked=true;? ?
? ? ? ? ? ? ? ? ? ? }? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? function clearall(){
? ? ? ? ? ? var hobby = document.getElementsByName("hobby");
? ? ? ? ? ??
? ? ? ? ?// 任務(wù)2? ??
? ? ? ? ?for(var i=0;i<hobby.length;i++){
? ? ? ? ? ? ?hobby[i].checked=false;
? ? ? ? ?}
? ? ? ? ? ??
? ? ? ? }
? ? ? ??
? ? ? ? function checkone(){
? ? ? ? ? ? var j=document.getElementById("wb").value;
? ? ? ??
? ? ? ? ?// 任務(wù)3
? ? ? ? ?if(j>0&&j<=6){?
? ? ? ? ?document.getElementById("hobby"+j).checked=true;
? ? ? ? }
? ? ? ? else {alert("請輸入1-6的值")};
? ? ? ? }
? ? ? ? </script>
? ? </body>
</html>
2018-09-27
<!DOCTYPE HTML>
<html>
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
? ? ? ? <title>無標題文檔</title>
? ? </head>
? ??
? ? <body>
? ? ? ? <form>
? ? ? ? ? 請選擇你愛好:<br>
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby1">? 音樂
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby2">? 登山
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby3">? 游泳
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby4">? 閱讀
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby5">? 打球
? ? ? ? ? <input type="checkbox" name="hobby" id="hobby6">? 跑步 <br>
? ? ? ? ? <input type="button" value = "全選" onclick = "checkall();">
? ? ? ? ? <input type="button" value = "全不選" onclick = "clearall();">
? ? ? ? ? <p>請輸入您要選擇愛好的序號,序號為1-6:</p>
? ? ? ? ? <input id="wb" name="wb" type="text" >
? ? ? ? ? <input name="ok" type="button" value="確定" onclick = "checkone();">
? ? ? ? </form>
? ? ? ? <script type="text/javascript">
? ? ? ? function checkall(){
? ? ? ? ? ? var hobby = document.getElementsByTagName("input");
? ? ? ? ? ? for(key in hobby)
? ? ? ? ? ?hobby[key].checked = true
? ? ? ? ? // 任務(wù)1?
? ? ? ? ? ?
? ? ? ? }
? ? ? ? function clearall(){
? ? ? ? ? ? var hobby = document.getElementsByName("hobby");
? ? ? ? ? ? ? ? ? ? ? ? for(key in hobby)
? ? ? ? ? ?hobby[key].checked = false
? ? ? ? ? ??
? ? ? ? ?// 任務(wù)2? ??
? ? ? ? ? ??
? ? ? ? }
? ? ? ??
? ? ? ? function checkone(){
? ? ? ? ? ? var j=document.getElementById("wb").value;
? ? ? ? var hobby = document.getElementsByTagName("input");
? ? ? ??
? ? ? ? hobby[j-1].checked = true;
? ? ? ? ?// 任務(wù)3
? ? ? ??
? ? ? ? }
? ? ? ??
? ? ? ? </script>
? ? </body>
</html>