微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

javascript – 在sweetAlert中输入文本

我正在使用自定义版本的 sweetalert来询问我的用户输入.我已经设法使一切工作,但有一个奇怪的行为,为了能够在输入框中输入文本,你必须先点击屏幕:
swal({
    title: "Aggiornamento profilo",text: '<br /><form method="post" id="taxcode-update" name="taxcodeUpdate"><input id="admin-tax-code" minlength="3" class="form-control wedding-input-text wizard-input-pad" type="text" name="taxCode" placeholder="Codice fiscale"></form>',type: "warning",showCancelButton: false,confirmButtonText: "Aggiorna il mio profilo",cloSEOnConfirm: false
},function () {
    swal("Deleted!","Your imaginary file has been deleted.","success");
});

工作实例:https://jsfiddle.net/fvkppx06/

解决方法

swal({
  title: "An input!",text: "Write something interesting:",type: "input",showCancelButton: true,cloSEOnConfirm: false,animation: "slide-from-top",inputPlaceholder: "Write something"
},function(inputValue){
  if (inputValue === false) return false;

  if (inputValue === "") {
    swal.showInputError("You need to write something!");
    return false
  }

  swal("Nice!","You wrote: " + inputValue,"success");
});

原文地址:https://www.jb51.cc/js/156244.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐