简体   繁体   English

如何从输入触发焦点框(对焦)

[英]How to trigger fancy box from an input (focusout)

I'm trying to trigger Fancybox when the user focuses out of an input box and the value within is over a fixed amount (25). 当用户将焦点移到输入框之外并且其中的值超过固定值(25)时,我尝试触发Fancybox。 The focus out and checking value code seem fine, but Fancy box throws the following error when triggered: 聚焦和检查值代码看起来不错,但是在触发时,花式框会引发以下错误:

Node cannot be inserted at the specified point in the hierarchy

My HTML is: 我的HTML是:

<input class='warning' type='text' name='cash' />

and th JS (in document ready) is: JS(准备就绪)为:

$(".warning").focusout(function() {
  if (Number(this.value) > 25)  {
    console.debug(this.value + " gt 25");
    $.fancybox({
      showCloseButton: false,
      href: 'warning.html'
    });
  }
})

I suspect the problem is in the $.fancybox bit, but I can't tell what it should be! 我怀疑问题出在$ .fancybox位,但我不知道应该是什么!

You are missing the closing brace on the if() clause. 您缺少if()子句的右括号。

http://jsfiddle.net/PxySJ/1/ works fine with it. http://jsfiddle.net/PxySJ/1/可以正常使用。

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

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