JS写两个input同时被选择触发一个事件

Cymheheheh 2017-09-18 11:56:19
document.getElementById("Action").selected || document.getElementById("over").selected= function Month() {}

报错
...全文
607 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Braska 2017-09-18
  • 打赏
  • 举报
回复
你这是定义方法都没调用。 而且同时被选中用的应该是&& 不是|| function Month() { alert("true"); } if (document.getElementById("Action").selected && document.getElementById("over").selected ) { Month(); }
当作看不见 2017-09-18
  • 打赏
  • 举报
回复
|| 逻辑与操作返回的是Boolean值啦,肯定不能这样绑定事件. 正确的做法, 先定义一个function selected(){//do something} document.getElementById("Action").selected = selected; document.getElementById("over").selected = selected;
never_66 2017-09-18
  • 打赏
  • 举报
回复
document.getElementById("Action").selected || document.getElementById("over").selected= function Month() {} 节点有问题,如果是ID选择器要加#,类选择器要加. 如document.getElementById("#Action")
  • 打赏
  • 举报
回复
什么东东,问题都问不清楚。。。

Web开发学习资料推荐
Web开发
javascript混淆加密

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧