简体   繁体   English

我的 function 的第二部分无法正常工作,但运行时没有显示错误

[英]I can't get the second part of my function to work, but there is no error shown when it's run

function dropAndRetract1(e) {
  if(e.type = 'mouseover') {
    ul.eq(0).slideDown(1000).show();
  } else if(e.type = 'mouseout') {
    ul.eq(0).slideUp(1000).hide();
  }
}

th.eq(0).on('mouseover mouseout', dropAndRetract1);
function dropAndRetract1(e) {
  if(e.type == 'mouseover') {
    ul.eq(0).slideDown(1000).show();
  } else if(e.type == 'mouseout') {
    ul.eq(0).slideUp(1000).hide();
  }
}

th.eq(0).on('mouseover mouseout', dropAndRetract1);

Error is not shown because you are assigning the value instead of comparing in if condition.未显示错误,因为您正在分配值而不是在 if 条件下进行比较。 Use "==" or "===" for comparison.使用“==”或“===”进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM