老师帮忙检查下代码

来源:6-7 编程练习

技术为王2383098363

2019-08-14 17:05:53

<!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 property(elem,propertyName,propertyValue){
    if(arguments.length<2 || arguments.length>3 ){
        throw new Error("请传入"+property.length+"个参数")
    }else if(arguments.length==2){
        return elem.style[propertyName];
    }else{
        return elem.style[propertyName]=propertyValue;
    }
}
var p=document.getElementById("test");
property(p,"background-color","orange");
property(p,"color",);
console.log(property(p,"background-color","orange"));
console.log(property(p,"color"));

// 在此处补充代码
</script> 
</body> 
</html>


写回答

1回答

好帮手慕嘟嘟

2019-08-14

同学你好,

老师运行了你的代码,效果是正确的,继续努力哦~

如果我的回答帮助了你,欢迎采纳,祝学习愉快~


0

0 学习 · 14456 问题

查看课程