已采纳回答 / 旺仔窝窝头
1、node[1].previousSibling.innerHTML:这里获得的是第一个<li></li>后面的空白符(nodeType=3,innerHTML=undefined),也即node[1]的上一个兄弟元素。2、若想跳过空白文本:function get_previousSibling(n){ var x=n.previousSibling;//首先取得n的上一个兄弟x while(x&&x.nodeType!=1){//判断x是否为元素节点(no...
2019-11-04
最新回答 / 晓之蛇
删除函数需要传入参数,定位删除的是哪一行:触发事件中onclick="del()"改为onclick="del(this)"del方法<...code...>
2019-11-04
已采纳回答 / 晓之蛇
js函数调用方式:1. 在<script>标签内调用 message();//调用函数,直接写函数名。2. 在HTML文件/标签中调用,如通过点击按钮后调用定义好的函数。 <input type="button" onclick="message()"> 所以在form标签里也能运行
2019-11-01
function num2(x,y){ //定义函数
if(x>y){ //函数体,判断两个整数比较的三种情况
return x;
}
else if(x<y){
return y;
}
else{
}
}
var res1 = num2(5,4);//调用函数,实现下面两组数中,返回较大值。
var res2 = num2(6,3);
document.write(" 5 和 4 的较大值是:"+res1+"<br>");
document.write(" 6 和 3 的较大值是:"+res2);
if(x>y){ //函数体,判断两个整数比较的三种情况
return x;
}
else if(x<y){
return y;
}
else{
}
}
var res1 = num2(5,4);//调用函数,实现下面两组数中,返回较大值。
var res2 = num2(6,3);
document.write(" 5 和 4 的较大值是:"+res1+"<br>");
document.write(" 6 和 3 的较大值是:"+res2);
最新回答 / 麻辣烫不加辣
<...code...>第一次筛选里的for循环条件,i<=infos.length,改为i<infos.length,即可。因为你的循环次数超过了数组本身长度导致了错误。
2019-10-31
已采纳回答 / RazorE
我觉得你的onclick并没传参数进去,所以会是undefine,写个add3(1,2,3),把参数带到函数里执行,才会有值,顺便把函数下面的直接调用去掉
2019-10-30
最赞回答 / qq_慕尼黑0053499
<!DOCTYPE html><html> <head> <title> new document </title> <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> <script type="text/javascript"> /*window.onload = function(){ ...
2019-10-30
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
var i = Math.random();
document.write(i*10 +"<br>");
document.write(Math.round(i*10));
</script>
</head>
<body>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Math </title>
<script type="text/javascript">
var i = Math.random();
document.write(i*10 +"<br>");
document.write(Math.round(i*10));
</script>
</head>
<body>
</body>
</html>
2019-10-29