function onc1() {
var n = document.getElementById("z");
var x = n.value;
if (n == "q") {
fun(x);
} else if (n == "e") {
fun1(x);
} else {
fun2(x);
}
}
js中获取了元素的id,想要根据id去做判断执行函数,可是获取的id类型是对象类型,转换之后也不能解决(初学者)
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- CSDN专家-sinJack 2021-11-30 13:49关注
function onc1() { var n = document.getElementById("z"); var x = n.value; var id=n.getAttribute("id"); if (id == "q") { fun(x); } else if (id== "e") { fun1(x); } else { fun2(x); } }本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录