如果传入的两个参数改为:是要返回属性的名称而不是值,要怎么写??
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title> arguments</title>
</head>
<body>
<p id="test" style="background-color: red; color: blue;">我是一个段落!</p>
<script type="text/javascript">
// 在此处补充代码
function setcss(elm,property,value){
if(arguments.length==2){
return elm.style[property];
}else if(arguments.length==3){
elm.style[property]=value;
}
}
var test=document.getElementById('test');
setcss(test,'background-color','orange');
console.log(setcss(test,'color'));
</script>
</body>
</html>14
收起
正在回答 回答被采纳积分+1
2回答

恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星